From ffb8180cc3ee7158e35a1c339ed4b7057f2bb0e4 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Tue, 27 Oct 2020 16:12:21 +0800 Subject: [PATCH 1/2] version,changelog,test.py --- .../azure-mgmt-apimanagement/CHANGELOG.md | 30 + .../azure-mgmt-apimanagement/README.md | 2 +- .../azure/mgmt/apimanagement/__init__.py | 18 +- .../apimanagement/_api_management_client.py | 350 +- .../mgmt/apimanagement/_configuration.py | 83 +- .../apimanagement/{version.py => _version.py} | 10 +- .../azure/mgmt/apimanagement/aio/__init__.py | 10 + .../aio/_api_management_client.py | 394 + .../mgmt/apimanagement/aio/_configuration.py | 67 + .../apimanagement/aio/operations/__init__.py | 145 + .../operations/_api_diagnostic_operations.py | 519 + .../aio/operations/_api_export_operations.py | 115 + .../_api_issue_attachment_operations.py | 463 + .../_api_issue_comment_operations.py | 459 + .../aio/operations/_api_issue_operations.py | 531 + .../_api_management_operations_operations.py | 104 + .../_api_management_service_operations.py | 1091 ++ ..._api_management_service_skus_operations.py | 119 + .../operations/_api_operation_operations.py | 535 + .../_api_operation_policy_operations.py | 438 + .../aio/operations/_api_operations.py | 685 ++ .../aio/operations/_api_policy_operations.py | 418 + .../aio/operations/_api_product_operations.py | 138 + .../aio/operations/_api_release_operations.py | 531 + .../operations/_api_revision_operations.py | 138 + .../aio/operations/_api_schema_operations.py | 510 + .../_api_tag_description_operations.py | 443 + .../operations/_api_version_set_operations.py | 494 + .../_authorization_server_operations.py | 557 + .../aio/operations/_backend_operations.py | 574 ++ .../aio/operations/_cache_operations.py | 488 + .../aio/operations/_certificate_operations.py | 419 + .../_content_type_content_item_operations.py | 407 + .../operations/_content_type_operations.py | 323 + .../_delegation_settings_operations.py | 363 + .../_deleted_services_operations.py | 229 + .../aio/operations/_diagnostic_operations.py | 495 + .../operations/_email_template_operations.py | 487 + .../aio/operations/_gateway_api_operations.py | 355 + ...teway_hostname_configuration_operations.py | 443 + .../aio/operations/_gateway_operations.py | 725 ++ .../aio/operations/_group_operations.py | 498 + .../aio/operations/_group_user_operations.py | 347 + .../_identity_provider_operations.py | 539 + .../aio/operations/_issue_operations.py | 205 + .../aio/operations/_logger_operations.py | 493 + .../aio/operations/_named_value_operations.py | 680 ++ .../operations/_network_status_operations.py | 168 + .../operations/_notification_operations.py | 259 + ...notification_recipient_email_operations.py | 304 + ..._notification_recipient_user_operations.py | 304 + .../_open_id_connect_provider_operations.py | 557 + .../aio/operations/_operation_operations.py | 149 + .../_policy_description_operations.py | 105 + .../aio/operations/_policy_operations.py | 389 + .../aio/operations/_product_api_operations.py | 350 + .../operations/_product_group_operations.py | 346 + .../aio/operations/_product_operations.py | 616 ++ .../operations/_product_policy_operations.py | 413 + .../_product_subscriptions_operations.py | 147 + .../_quota_by_counter_keys_operations.py | 188 + .../_quota_by_period_keys_operations.py | 195 + .../aio/operations/_region_operations.py | 117 + .../aio/operations/_reports_operations.py | 857 ++ .../_sign_in_settings_operations.py | 308 + .../_sign_up_settings_operations.py | 314 + .../operations/_subscription_operations.py | 722 ++ .../aio/operations/_tag_operations.py | 1651 +++ .../operations/_tag_resource_operations.py | 146 + .../_tenant_access_git_operations.py | 291 + .../operations/_tenant_access_operations.py | 435 + .../_tenant_configuration_operations.py | 517 + .../_user_confirmation_password_operations.py | 107 + .../aio/operations/_user_group_operations.py | 142 + .../operations/_user_identities_operations.py | 121 + .../aio/operations/_user_operations.py | 665 ++ .../_user_subscription_operations.py | 145 + .../mgmt/apimanagement/models/__init__.py | 810 +- .../models/_api_management_client_enums.py | 620 +- .../mgmt/apimanagement/models/_models.py | 8080 ++++++++++----- .../mgmt/apimanagement/models/_models_py3.py | 9125 ++++++++++++----- .../apimanagement/models/_paged_models.py | 482 - .../mgmt/apimanagement/operations/__init__.py | 21 +- .../operations/_api_diagnostic_operations.py | 581 +- .../operations/_api_export_operations.py | 123 +- .../_api_issue_attachment_operations.py | 519 +- .../_api_issue_comment_operations.py | 515 +- .../operations/_api_issue_operations.py | 581 +- .../operations/_api_management_operations.py | 103 - .../_api_management_operations_operations.py | 109 + .../_api_management_service_operations.py | 1390 +-- ..._api_management_service_skus_operations.py | 122 +- .../operations/_api_operation_operations.py | 605 +- .../_api_operation_policy_operations.py | 506 +- .../operations/_api_operations.py | 792 +- .../operations/_api_policy_operations.py | 486 +- .../operations/_api_product_operations.py | 137 +- .../operations/_api_release_operations.py | 602 +- .../operations/_api_revision_operations.py | 137 +- .../operations/_api_schema_operations.py | 589 +- .../_api_tag_description_operations.py | 503 +- .../operations/_api_version_set_operations.py | 557 +- .../_authorization_server_operations.py | 619 +- .../operations/_backend_operations.py | 657 +- .../operations/_cache_operations.py | 551 +- .../operations/_certificate_operations.py | 482 +- .../_content_type_content_item_operations.py | 416 + .../operations/_content_type_operations.py | 331 + .../_delegation_settings_operations.py | 413 +- .../_deleted_services_operations.py | 236 + .../operations/_diagnostic_operations.py | 551 +- .../operations/_email_template_operations.py | 613 +- .../operations/_gateway_api_operations.py | 390 +- ...teway_hostname_configuration_operations.py | 508 +- .../operations/_gateway_operations.py | 836 +- .../operations/_group_operations.py | 563 +- .../operations/_group_user_operations.py | 379 +- .../_identity_provider_operations.py | 634 +- .../operations/_issue_operations.py | 224 +- .../operations/_logger_operations.py | 569 +- .../operations/_named_value_operations.py | 819 +- .../operations/_network_status_operations.py | 191 +- .../operations/_notification_operations.py | 285 +- ...notification_recipient_email_operations.py | 352 +- ..._notification_recipient_user_operations.py | 364 +- .../_open_id_connect_provider_operations.py | 626 +- .../operations/_operation_operations.py | 154 +- .../_policy_description_operations.py | 107 +- .../operations/_policy_operations.py | 455 +- .../operations/_product_api_operations.py | 382 +- .../operations/_product_group_operations.py | 376 +- .../operations/_product_operations.py | 683 +- .../operations/_product_policy_operations.py | 473 +- .../_product_subscriptions_operations.py | 156 +- .../_quota_by_counter_keys_operations.py | 219 +- .../_quota_by_period_keys_operations.py | 218 +- .../operations/_region_operations.py | 122 +- .../operations/_reports_operations.py | 983 +- .../_sign_in_settings_operations.py | 343 +- .../_sign_up_settings_operations.py | 351 +- .../operations/_subscription_operations.py | 842 +- .../operations/_tag_operations.py | 1866 ++-- .../operations/_tag_resource_operations.py | 161 +- .../_tenant_access_git_operations.py | 330 +- .../operations/_tenant_access_operations.py | 496 +- .../_tenant_configuration_operations.py | 652 +- .../_user_confirmation_password_operations.py | 105 +- .../operations/_user_group_operations.py | 144 +- .../operations/_user_identities_operations.py | 126 +- .../operations/_user_operations.py | 759 +- .../_user_subscription_operations.py | 153 +- .../azure/mgmt/apimanagement/py.typed | 1 + .../azure-mgmt-apimanagement/setup.py | 4 +- .../test_apimanagement.test_apiservice2.yaml | 58 + .../test_apimanagement.test_usr.yaml | 47 + .../tests/test_apimanagement.py | 56 + 156 files changed, 58670 insertions(+), 20351 deletions(-) rename sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/{version.py => _version.py} (84%) create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_content_item_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py delete mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_paged_models.py delete mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_content_item_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/py.typed create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_apiservice2.yaml create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_usr.yaml create mode 100644 sdk/apimanagement/azure-mgmt-apimanagement/tests/test_apimanagement.py diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md b/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md index fd3540d40a37..878550e79665 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md +++ b/sdk/apimanagement/azure-mgmt-apimanagement/CHANGELOG.md @@ -1,5 +1,35 @@ # Release History +## 1.0.0b1 (2020-10-31) + +This is beta preview version. +For detailed changelog please refer to equivalent stable version 0.2.0(https://pypi.org/project/azure-mgmt-apimanagement/0.2.0/) + +This version uses a next-generation code generator that introduces important breaking changes, but also important new features (like unified authentication and async programming). + +**General breaking changes** + +- Credential system has been completly revamped: + + - `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported, use the `azure-identity` classes instead: https://pypi.org/project/azure-identity/ + - `credentials` parameter has been renamed `credential` + +- The `config` attribute no longer exists on a client, configuration should be passed as kwarg. Example: `MyClient(credential, subscription_id, enable_logging=True)`. For a complete set of + supported options, see the [parameters accept in init documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) +- You can't import a `version` module anymore, use `__version__` instead +- Operations that used to return a `msrest.polling.LROPoller` now returns a `azure.core.polling.LROPoller` and are prefixed with `begin_`. +- Exceptions tree have been simplified and most exceptions are now `azure.core.exceptions.HttpResponseError` (`CloudError` has been removed). +- Most of the operation kwarg have changed. Some of the most noticeable: + + - `raw` has been removed. Equivalent feature can be found using `cls`, a callback that will give access to internal HTTP response for advanced user + - For a complete set of supported options, see the [parameters accept in Request documentation of azure-core](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#available-policies) + +**General new features** + +- Type annotations support using `typing`. SDKs are mypy ready. +- This client has now stable and official support for async. Check the `aio` namespace of your package to find the async client. +- This client now support natively tracing library like OpenCensus or OpenTelemetry. See this [tracing quickstart](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/core/azure-core-tracing-opentelemetry) for an overview. + ## 0.2.0 (2020-03-25) **Features** diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/README.md b/sdk/apimanagement/azure-mgmt-apimanagement/README.md index cd8514051b3a..08d5087827ee 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/README.md +++ b/sdk/apimanagement/azure-mgmt-apimanagement/README.md @@ -6,7 +6,7 @@ For a more complete view of Azure libraries, see the [azure sdk python release]( # Usage - + For code examples, see [API Management](https://docs.microsoft.com/python/api/overview/azure/) on docs.microsoft.com. 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 f361c01f449f..2bdfd1fb9851 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/__init__.py @@ -1,19 +1,19 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._configuration import ApiManagementClientConfiguration from ._api_management_client import ApiManagementClient -__all__ = ['ApiManagementClient', 'ApiManagementClientConfiguration'] - -from .version import VERSION +from ._version import VERSION __version__ = VERSION +__all__ = ['ApiManagementClient'] +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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 b7ddabddd99a..c1be23cb4e3a 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 @@ -1,16 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import SDKClient -from msrest import Serializer, Deserializer +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential from ._configuration import ApiManagementClientConfiguration from .operations import ApiOperations @@ -28,12 +33,16 @@ from .operations import ApiIssueAttachmentOperations from .operations import ApiTagDescriptionOperations from .operations import OperationOperations +from .operations import ApiExportOperations from .operations import ApiVersionSetOperations from .operations import AuthorizationServerOperations from .operations import BackendOperations from .operations import CacheOperations from .operations import CertificateOperations -from .operations import ApiManagementOperations +from .operations import ContentTypeOperations +from .operations import ContentTypeContentItemOperations +from .operations import DeletedServicesOperations +from .operations import ApiManagementOperationsOperations from .operations import ApiManagementServiceSkusOperations from .operations import ApiManagementServiceOperations from .operations import DiagnosticOperations @@ -76,291 +85,316 @@ from .operations import UserSubscriptionOperations from .operations import UserIdentitiesOperations from .operations import UserConfirmationPasswordOperations -from .operations import ApiExportOperations from . import models -class ApiManagementClient(SDKClient): - """ApiManagement Client - - :ivar config: Configuration for client. - :vartype config: ApiManagementClientConfiguration +class ApiManagementClient(object): + """ApiManagement Client. - :ivar api: Api operations + :ivar api: ApiOperations operations :vartype api: azure.mgmt.apimanagement.operations.ApiOperations - :ivar api_revision: ApiRevision operations + :ivar api_revision: ApiRevisionOperations operations :vartype api_revision: azure.mgmt.apimanagement.operations.ApiRevisionOperations - :ivar api_release: ApiRelease operations + :ivar api_release: ApiReleaseOperations operations :vartype api_release: azure.mgmt.apimanagement.operations.ApiReleaseOperations - :ivar api_operation: ApiOperation operations + :ivar api_operation: ApiOperationOperations operations :vartype api_operation: azure.mgmt.apimanagement.operations.ApiOperationOperations - :ivar api_operation_policy: ApiOperationPolicy operations + :ivar api_operation_policy: ApiOperationPolicyOperations operations :vartype api_operation_policy: azure.mgmt.apimanagement.operations.ApiOperationPolicyOperations - :ivar tag: Tag operations + :ivar tag: TagOperations operations :vartype tag: azure.mgmt.apimanagement.operations.TagOperations - :ivar api_product: ApiProduct operations + :ivar api_product: ApiProductOperations operations :vartype api_product: azure.mgmt.apimanagement.operations.ApiProductOperations - :ivar api_policy: ApiPolicy operations + :ivar api_policy: ApiPolicyOperations operations :vartype api_policy: azure.mgmt.apimanagement.operations.ApiPolicyOperations - :ivar api_schema: ApiSchema operations + :ivar api_schema: ApiSchemaOperations operations :vartype api_schema: azure.mgmt.apimanagement.operations.ApiSchemaOperations - :ivar api_diagnostic: ApiDiagnostic operations + :ivar api_diagnostic: ApiDiagnosticOperations operations :vartype api_diagnostic: azure.mgmt.apimanagement.operations.ApiDiagnosticOperations - :ivar api_issue: ApiIssue operations + :ivar api_issue: ApiIssueOperations operations :vartype api_issue: azure.mgmt.apimanagement.operations.ApiIssueOperations - :ivar api_issue_comment: ApiIssueComment operations + :ivar api_issue_comment: ApiIssueCommentOperations operations :vartype api_issue_comment: azure.mgmt.apimanagement.operations.ApiIssueCommentOperations - :ivar api_issue_attachment: ApiIssueAttachment operations + :ivar api_issue_attachment: ApiIssueAttachmentOperations operations :vartype api_issue_attachment: azure.mgmt.apimanagement.operations.ApiIssueAttachmentOperations - :ivar api_tag_description: ApiTagDescription operations + :ivar api_tag_description: ApiTagDescriptionOperations operations :vartype api_tag_description: azure.mgmt.apimanagement.operations.ApiTagDescriptionOperations - :ivar operation: Operation operations + :ivar operation: OperationOperations operations :vartype operation: azure.mgmt.apimanagement.operations.OperationOperations - :ivar api_version_set: ApiVersionSet operations + :ivar api_export: ApiExportOperations operations + :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations + :ivar api_version_set: ApiVersionSetOperations operations :vartype api_version_set: azure.mgmt.apimanagement.operations.ApiVersionSetOperations - :ivar authorization_server: AuthorizationServer operations + :ivar authorization_server: AuthorizationServerOperations operations :vartype authorization_server: azure.mgmt.apimanagement.operations.AuthorizationServerOperations - :ivar backend: Backend operations + :ivar backend: BackendOperations operations :vartype backend: azure.mgmt.apimanagement.operations.BackendOperations - :ivar cache: Cache operations + :ivar cache: CacheOperations operations :vartype cache: azure.mgmt.apimanagement.operations.CacheOperations - :ivar certificate: Certificate operations + :ivar certificate: CertificateOperations operations :vartype certificate: azure.mgmt.apimanagement.operations.CertificateOperations - :ivar api_management_operations: ApiManagementOperations operations - :vartype api_management_operations: azure.mgmt.apimanagement.operations.ApiManagementOperations - :ivar api_management_service_skus: ApiManagementServiceSkus operations + :ivar content_type: ContentTypeOperations operations + :vartype content_type: azure.mgmt.apimanagement.operations.ContentTypeOperations + :ivar content_type_content_item: ContentTypeContentItemOperations operations + :vartype content_type_content_item: azure.mgmt.apimanagement.operations.ContentTypeContentItemOperations + :ivar deleted_services: DeletedServicesOperations operations + :vartype deleted_services: azure.mgmt.apimanagement.operations.DeletedServicesOperations + :ivar api_management_operations: ApiManagementOperationsOperations operations + :vartype api_management_operations: azure.mgmt.apimanagement.operations.ApiManagementOperationsOperations + :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations :vartype api_management_service_skus: azure.mgmt.apimanagement.operations.ApiManagementServiceSkusOperations - :ivar api_management_service: ApiManagementService operations + :ivar api_management_service: ApiManagementServiceOperations operations :vartype api_management_service: azure.mgmt.apimanagement.operations.ApiManagementServiceOperations - :ivar diagnostic: Diagnostic operations + :ivar diagnostic: DiagnosticOperations operations :vartype diagnostic: azure.mgmt.apimanagement.operations.DiagnosticOperations - :ivar email_template: EmailTemplate operations + :ivar email_template: EmailTemplateOperations operations :vartype email_template: azure.mgmt.apimanagement.operations.EmailTemplateOperations - :ivar gateway: Gateway operations + :ivar gateway: GatewayOperations operations :vartype gateway: azure.mgmt.apimanagement.operations.GatewayOperations - :ivar gateway_hostname_configuration: GatewayHostnameConfiguration operations + :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.operations.GatewayHostnameConfigurationOperations - :ivar gateway_api: GatewayApi operations + :ivar gateway_api: GatewayApiOperations operations :vartype gateway_api: azure.mgmt.apimanagement.operations.GatewayApiOperations - :ivar group: Group operations + :ivar group: GroupOperations operations :vartype group: azure.mgmt.apimanagement.operations.GroupOperations - :ivar group_user: GroupUser operations + :ivar group_user: GroupUserOperations operations :vartype group_user: azure.mgmt.apimanagement.operations.GroupUserOperations - :ivar identity_provider: IdentityProvider operations + :ivar identity_provider: IdentityProviderOperations operations :vartype identity_provider: azure.mgmt.apimanagement.operations.IdentityProviderOperations - :ivar issue: Issue operations + :ivar issue: IssueOperations operations :vartype issue: azure.mgmt.apimanagement.operations.IssueOperations - :ivar logger: Logger operations + :ivar logger: LoggerOperations operations :vartype logger: azure.mgmt.apimanagement.operations.LoggerOperations - :ivar named_value: NamedValue operations + :ivar named_value: NamedValueOperations operations :vartype named_value: azure.mgmt.apimanagement.operations.NamedValueOperations - :ivar network_status: NetworkStatus operations + :ivar network_status: NetworkStatusOperations operations :vartype network_status: azure.mgmt.apimanagement.operations.NetworkStatusOperations - :ivar notification: Notification operations + :ivar notification: NotificationOperations operations :vartype notification: azure.mgmt.apimanagement.operations.NotificationOperations - :ivar notification_recipient_user: NotificationRecipientUser operations + :ivar notification_recipient_user: NotificationRecipientUserOperations operations :vartype notification_recipient_user: azure.mgmt.apimanagement.operations.NotificationRecipientUserOperations - :ivar notification_recipient_email: NotificationRecipientEmail operations + :ivar notification_recipient_email: NotificationRecipientEmailOperations operations :vartype notification_recipient_email: azure.mgmt.apimanagement.operations.NotificationRecipientEmailOperations - :ivar open_id_connect_provider: OpenIdConnectProvider operations + :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations :vartype open_id_connect_provider: azure.mgmt.apimanagement.operations.OpenIdConnectProviderOperations - :ivar policy: Policy operations + :ivar policy: PolicyOperations operations :vartype policy: azure.mgmt.apimanagement.operations.PolicyOperations - :ivar policy_description: PolicyDescription operations + :ivar policy_description: PolicyDescriptionOperations operations :vartype policy_description: azure.mgmt.apimanagement.operations.PolicyDescriptionOperations - :ivar sign_in_settings: SignInSettings operations + :ivar sign_in_settings: SignInSettingsOperations operations :vartype sign_in_settings: azure.mgmt.apimanagement.operations.SignInSettingsOperations - :ivar sign_up_settings: SignUpSettings operations + :ivar sign_up_settings: SignUpSettingsOperations operations :vartype sign_up_settings: azure.mgmt.apimanagement.operations.SignUpSettingsOperations - :ivar delegation_settings: DelegationSettings operations + :ivar delegation_settings: DelegationSettingsOperations operations :vartype delegation_settings: azure.mgmt.apimanagement.operations.DelegationSettingsOperations - :ivar product: Product operations + :ivar product: ProductOperations operations :vartype product: azure.mgmt.apimanagement.operations.ProductOperations - :ivar product_api: ProductApi operations + :ivar product_api: ProductApiOperations operations :vartype product_api: azure.mgmt.apimanagement.operations.ProductApiOperations - :ivar product_group: ProductGroup operations + :ivar product_group: ProductGroupOperations operations :vartype product_group: azure.mgmt.apimanagement.operations.ProductGroupOperations - :ivar product_subscriptions: ProductSubscriptions operations + :ivar product_subscriptions: ProductSubscriptionsOperations operations :vartype product_subscriptions: azure.mgmt.apimanagement.operations.ProductSubscriptionsOperations - :ivar product_policy: ProductPolicy operations + :ivar product_policy: ProductPolicyOperations operations :vartype product_policy: azure.mgmt.apimanagement.operations.ProductPolicyOperations - :ivar quota_by_counter_keys: QuotaByCounterKeys operations + :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations :vartype quota_by_counter_keys: azure.mgmt.apimanagement.operations.QuotaByCounterKeysOperations - :ivar quota_by_period_keys: QuotaByPeriodKeys operations + :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations :vartype quota_by_period_keys: azure.mgmt.apimanagement.operations.QuotaByPeriodKeysOperations - :ivar region: Region operations + :ivar region: RegionOperations operations :vartype region: azure.mgmt.apimanagement.operations.RegionOperations - :ivar reports: Reports operations + :ivar reports: ReportsOperations operations :vartype reports: azure.mgmt.apimanagement.operations.ReportsOperations - :ivar subscription: Subscription operations + :ivar subscription: SubscriptionOperations operations :vartype subscription: azure.mgmt.apimanagement.operations.SubscriptionOperations - :ivar tag_resource: TagResource operations + :ivar tag_resource: TagResourceOperations operations :vartype tag_resource: azure.mgmt.apimanagement.operations.TagResourceOperations - :ivar tenant_access: TenantAccess operations + :ivar tenant_access: TenantAccessOperations operations :vartype tenant_access: azure.mgmt.apimanagement.operations.TenantAccessOperations - :ivar tenant_access_git: TenantAccessGit operations + :ivar tenant_access_git: TenantAccessGitOperations operations :vartype tenant_access_git: azure.mgmt.apimanagement.operations.TenantAccessGitOperations - :ivar tenant_configuration: TenantConfiguration operations + :ivar tenant_configuration: TenantConfigurationOperations operations :vartype tenant_configuration: azure.mgmt.apimanagement.operations.TenantConfigurationOperations - :ivar user: User operations + :ivar user: UserOperations operations :vartype user: azure.mgmt.apimanagement.operations.UserOperations - :ivar user_group: UserGroup operations + :ivar user_group: UserGroupOperations operations :vartype user_group: azure.mgmt.apimanagement.operations.UserGroupOperations - :ivar user_subscription: UserSubscription operations + :ivar user_subscription: UserSubscriptionOperations operations :vartype user_subscription: azure.mgmt.apimanagement.operations.UserSubscriptionOperations - :ivar user_identities: UserIdentities operations + :ivar user_identities: UserIdentitiesOperations operations :vartype user_identities: azure.mgmt.apimanagement.operations.UserIdentitiesOperations - :ivar user_confirmation_password: UserConfirmationPassword operations + :ivar user_confirmation_password: UserConfirmationPasswordOperations operations :vartype user_confirmation_password: azure.mgmt.apimanagement.operations.UserConfirmationPasswordOperations - :ivar api_export: ApiExport operations - :vartype api_export: azure.mgmt.apimanagement.operations.ApiExportOperations - - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription credentials which uniquely identify - Microsoft Azure subscription. The subscription ID forms part of the URI - for every service call. + :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 str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, credentials, subscription_id, base_url=None): - - self.config = ApiManagementClientConfiguration(credentials, subscription_id, base_url) - super(ApiManagementClient, self).__init__(self.config.credentials, self.config) + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = ApiManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2019-12-01' self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.api = ApiOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_revision = ApiRevisionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_release = ApiReleaseOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_operation = ApiOperationOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_operation_policy = ApiOperationPolicyOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tag = TagOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_product = ApiProductOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_policy = ApiPolicyOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_schema = ApiSchemaOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_diagnostic = ApiDiagnosticOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_issue = ApiIssueOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_issue_comment = ApiIssueCommentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_issue_attachment = ApiIssueAttachmentOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.api_tag_description = ApiTagDescriptionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.operation = OperationOperations( - self._client, self.config, self._serialize, self._deserialize) + 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._client, self._config, self._serialize, self._deserialize) self.authorization_server = AuthorizationServerOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.backend = BackendOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.cache = CacheOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.certificate = CertificateOperations( - self._client, self.config, self._serialize, self._deserialize) - self.api_management_operations = ApiManagementOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + self.content_type = ContentTypeOperations( + self._client, self._config, self._serialize, self._deserialize) + self.content_type_content_item = ContentTypeContentItemOperations( + 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._client, self._config, self._serialize, self._deserialize) self.api_management_service = ApiManagementServiceOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.diagnostic = DiagnosticOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.email_template = EmailTemplateOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.gateway = GatewayOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.gateway_hostname_configuration = GatewayHostnameConfigurationOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.gateway_api = GatewayApiOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.group = GroupOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.group_user = GroupUserOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.identity_provider = IdentityProviderOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.issue = IssueOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.logger = LoggerOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.named_value = NamedValueOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.network_status = NetworkStatusOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.notification = NotificationOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.notification_recipient_user = NotificationRecipientUserOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.notification_recipient_email = NotificationRecipientEmailOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.open_id_connect_provider = OpenIdConnectProviderOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy = PolicyOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.policy_description = PolicyDescriptionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.sign_in_settings = SignInSettingsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.sign_up_settings = SignUpSettingsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.delegation_settings = DelegationSettingsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.product = ProductOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.product_api = ProductApiOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.product_group = ProductGroupOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.product_subscriptions = ProductSubscriptionsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.product_policy = ProductPolicyOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.quota_by_counter_keys = QuotaByCounterKeysOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.quota_by_period_keys = QuotaByPeriodKeysOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.region = RegionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.reports = ReportsOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.subscription = SubscriptionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tag_resource = TagResourceOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenant_access = TenantAccessOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenant_access_git = TenantAccessGitOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.tenant_configuration = TenantConfigurationOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.user = UserOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.user_group = UserGroupOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.user_subscription = UserSubscriptionOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.user_identities = UserIdentitiesOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) self.user_confirmation_password = UserConfirmationPasswordOperations( - self._client, self.config, self._serialize, self._deserialize) - self.api_export = ApiExportOperations( - self._client, self.config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> ApiManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) 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 ec13079f346d..3e2f794be50f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_configuration.py @@ -1,50 +1,71 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrestazure import AzureConfiguration -from .version import VERSION +from typing import TYPE_CHECKING +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class ApiManagementClientConfiguration(Configuration): + """Configuration for ApiManagementClient. -class ApiManagementClientConfiguration(AzureConfiguration): - """Configuration for ApiManagementClient Note that all parameters used to create this instance are saved as instance attributes. - :param credentials: Credentials needed for the client to connect to Azure. - :type credentials: :mod:`A msrestazure Credentials - object` - :param subscription_id: Subscription credentials which uniquely identify - Microsoft Azure subscription. The subscription ID forms part of the URI - for every service call. + :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 str base_url: Service URL """ def __init__( - self, credentials, subscription_id, base_url=None): - - if credentials is None: - raise ValueError("Parameter 'credentials' must not be None.") + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - if not base_url: - base_url = 'https://management.azure.com' - - super(ApiManagementClientConfiguration, self).__init__(base_url) - - # Starting Autorest.Python 4.0.64, make connection pool activated by default - self.keep_alive = True + super(ApiManagementClientConfiguration, self).__init__(**kwargs) - self.add_user_agent('azure-mgmt-apimanagement/{}'.format(VERSION)) - self.add_user_agent('Azure-SDK-For-Python') - - self.credentials = credentials + self.credential = credential self.subscription_id = subscription_id + self.api_version = "2020-06-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/version.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py similarity index 84% rename from sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/version.py rename to sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py index 9bd1dfac7ecb..e5754a47ce68 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/version.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/_version.py @@ -1,13 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "0.2.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 new file mode 100644 index 000000000000..8ef78e4dcbb0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._api_management_client import ApiManagementClient +__all__ = ['ApiManagementClient'] 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 new file mode 100644 index 000000000000..2430b6d9c67f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_api_management_client.py @@ -0,0 +1,394 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import ApiManagementClientConfiguration +from .operations import ApiOperations +from .operations import ApiRevisionOperations +from .operations import ApiReleaseOperations +from .operations import ApiOperationOperations +from .operations import ApiOperationPolicyOperations +from .operations import TagOperations +from .operations import ApiProductOperations +from .operations import ApiPolicyOperations +from .operations import ApiSchemaOperations +from .operations import ApiDiagnosticOperations +from .operations import ApiIssueOperations +from .operations import ApiIssueCommentOperations +from .operations import ApiIssueAttachmentOperations +from .operations import ApiTagDescriptionOperations +from .operations import OperationOperations +from .operations import ApiExportOperations +from .operations import ApiVersionSetOperations +from .operations import AuthorizationServerOperations +from .operations import BackendOperations +from .operations import CacheOperations +from .operations import CertificateOperations +from .operations import ContentTypeOperations +from .operations import ContentTypeContentItemOperations +from .operations import DeletedServicesOperations +from .operations import ApiManagementOperationsOperations +from .operations import ApiManagementServiceSkusOperations +from .operations import ApiManagementServiceOperations +from .operations import DiagnosticOperations +from .operations import EmailTemplateOperations +from .operations import GatewayOperations +from .operations import GatewayHostnameConfigurationOperations +from .operations import GatewayApiOperations +from .operations import GroupOperations +from .operations import GroupUserOperations +from .operations import IdentityProviderOperations +from .operations import IssueOperations +from .operations import LoggerOperations +from .operations import NamedValueOperations +from .operations import NetworkStatusOperations +from .operations import NotificationOperations +from .operations import NotificationRecipientUserOperations +from .operations import NotificationRecipientEmailOperations +from .operations import OpenIdConnectProviderOperations +from .operations import PolicyOperations +from .operations import PolicyDescriptionOperations +from .operations import SignInSettingsOperations +from .operations import SignUpSettingsOperations +from .operations import DelegationSettingsOperations +from .operations import ProductOperations +from .operations import ProductApiOperations +from .operations import ProductGroupOperations +from .operations import ProductSubscriptionsOperations +from .operations import ProductPolicyOperations +from .operations import QuotaByCounterKeysOperations +from .operations import QuotaByPeriodKeysOperations +from .operations import RegionOperations +from .operations import ReportsOperations +from .operations import SubscriptionOperations +from .operations import TagResourceOperations +from .operations import TenantAccessOperations +from .operations import TenantAccessGitOperations +from .operations import TenantConfigurationOperations +from .operations import UserOperations +from .operations import UserGroupOperations +from .operations import UserSubscriptionOperations +from .operations import UserIdentitiesOperations +from .operations import UserConfirmationPasswordOperations +from .. import models + + +class ApiManagementClient(object): + """ApiManagement Client. + + :ivar api: ApiOperations operations + :vartype api: azure.mgmt.apimanagement.aio.operations.ApiOperations + :ivar api_revision: ApiRevisionOperations operations + :vartype api_revision: azure.mgmt.apimanagement.aio.operations.ApiRevisionOperations + :ivar api_release: ApiReleaseOperations operations + :vartype api_release: azure.mgmt.apimanagement.aio.operations.ApiReleaseOperations + :ivar api_operation: ApiOperationOperations operations + :vartype api_operation: azure.mgmt.apimanagement.aio.operations.ApiOperationOperations + :ivar api_operation_policy: ApiOperationPolicyOperations operations + :vartype api_operation_policy: azure.mgmt.apimanagement.aio.operations.ApiOperationPolicyOperations + :ivar tag: TagOperations operations + :vartype tag: azure.mgmt.apimanagement.aio.operations.TagOperations + :ivar api_product: ApiProductOperations operations + :vartype api_product: azure.mgmt.apimanagement.aio.operations.ApiProductOperations + :ivar api_policy: ApiPolicyOperations operations + :vartype api_policy: azure.mgmt.apimanagement.aio.operations.ApiPolicyOperations + :ivar api_schema: ApiSchemaOperations operations + :vartype api_schema: azure.mgmt.apimanagement.aio.operations.ApiSchemaOperations + :ivar api_diagnostic: ApiDiagnosticOperations operations + :vartype api_diagnostic: azure.mgmt.apimanagement.aio.operations.ApiDiagnosticOperations + :ivar api_issue: ApiIssueOperations operations + :vartype api_issue: azure.mgmt.apimanagement.aio.operations.ApiIssueOperations + :ivar api_issue_comment: ApiIssueCommentOperations operations + :vartype api_issue_comment: azure.mgmt.apimanagement.aio.operations.ApiIssueCommentOperations + :ivar api_issue_attachment: ApiIssueAttachmentOperations operations + :vartype api_issue_attachment: azure.mgmt.apimanagement.aio.operations.ApiIssueAttachmentOperations + :ivar api_tag_description: ApiTagDescriptionOperations operations + :vartype api_tag_description: azure.mgmt.apimanagement.aio.operations.ApiTagDescriptionOperations + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.apimanagement.aio.operations.OperationOperations + :ivar api_export: ApiExportOperations operations + :vartype api_export: azure.mgmt.apimanagement.aio.operations.ApiExportOperations + :ivar api_version_set: ApiVersionSetOperations operations + :vartype api_version_set: azure.mgmt.apimanagement.aio.operations.ApiVersionSetOperations + :ivar authorization_server: AuthorizationServerOperations operations + :vartype authorization_server: azure.mgmt.apimanagement.aio.operations.AuthorizationServerOperations + :ivar backend: BackendOperations operations + :vartype backend: azure.mgmt.apimanagement.aio.operations.BackendOperations + :ivar cache: CacheOperations operations + :vartype cache: azure.mgmt.apimanagement.aio.operations.CacheOperations + :ivar certificate: CertificateOperations operations + :vartype certificate: azure.mgmt.apimanagement.aio.operations.CertificateOperations + :ivar content_type: ContentTypeOperations operations + :vartype content_type: azure.mgmt.apimanagement.aio.operations.ContentTypeOperations + :ivar content_type_content_item: ContentTypeContentItemOperations operations + :vartype content_type_content_item: azure.mgmt.apimanagement.aio.operations.ContentTypeContentItemOperations + :ivar deleted_services: DeletedServicesOperations operations + :vartype deleted_services: azure.mgmt.apimanagement.aio.operations.DeletedServicesOperations + :ivar api_management_operations: ApiManagementOperationsOperations operations + :vartype api_management_operations: azure.mgmt.apimanagement.aio.operations.ApiManagementOperationsOperations + :ivar api_management_service_skus: ApiManagementServiceSkusOperations operations + :vartype api_management_service_skus: azure.mgmt.apimanagement.aio.operations.ApiManagementServiceSkusOperations + :ivar api_management_service: ApiManagementServiceOperations operations + :vartype api_management_service: azure.mgmt.apimanagement.aio.operations.ApiManagementServiceOperations + :ivar diagnostic: DiagnosticOperations operations + :vartype diagnostic: azure.mgmt.apimanagement.aio.operations.DiagnosticOperations + :ivar email_template: EmailTemplateOperations operations + :vartype email_template: azure.mgmt.apimanagement.aio.operations.EmailTemplateOperations + :ivar gateway: GatewayOperations operations + :vartype gateway: azure.mgmt.apimanagement.aio.operations.GatewayOperations + :ivar gateway_hostname_configuration: GatewayHostnameConfigurationOperations operations + :vartype gateway_hostname_configuration: azure.mgmt.apimanagement.aio.operations.GatewayHostnameConfigurationOperations + :ivar gateway_api: GatewayApiOperations operations + :vartype gateway_api: azure.mgmt.apimanagement.aio.operations.GatewayApiOperations + :ivar group: GroupOperations operations + :vartype group: azure.mgmt.apimanagement.aio.operations.GroupOperations + :ivar group_user: GroupUserOperations operations + :vartype group_user: azure.mgmt.apimanagement.aio.operations.GroupUserOperations + :ivar identity_provider: IdentityProviderOperations operations + :vartype identity_provider: azure.mgmt.apimanagement.aio.operations.IdentityProviderOperations + :ivar issue: IssueOperations operations + :vartype issue: azure.mgmt.apimanagement.aio.operations.IssueOperations + :ivar logger: LoggerOperations operations + :vartype logger: azure.mgmt.apimanagement.aio.operations.LoggerOperations + :ivar named_value: NamedValueOperations operations + :vartype named_value: azure.mgmt.apimanagement.aio.operations.NamedValueOperations + :ivar network_status: NetworkStatusOperations operations + :vartype network_status: azure.mgmt.apimanagement.aio.operations.NetworkStatusOperations + :ivar notification: NotificationOperations operations + :vartype notification: azure.mgmt.apimanagement.aio.operations.NotificationOperations + :ivar notification_recipient_user: NotificationRecipientUserOperations operations + :vartype notification_recipient_user: azure.mgmt.apimanagement.aio.operations.NotificationRecipientUserOperations + :ivar notification_recipient_email: NotificationRecipientEmailOperations operations + :vartype notification_recipient_email: azure.mgmt.apimanagement.aio.operations.NotificationRecipientEmailOperations + :ivar open_id_connect_provider: OpenIdConnectProviderOperations operations + :vartype open_id_connect_provider: azure.mgmt.apimanagement.aio.operations.OpenIdConnectProviderOperations + :ivar policy: PolicyOperations operations + :vartype policy: azure.mgmt.apimanagement.aio.operations.PolicyOperations + :ivar policy_description: PolicyDescriptionOperations operations + :vartype policy_description: azure.mgmt.apimanagement.aio.operations.PolicyDescriptionOperations + :ivar sign_in_settings: SignInSettingsOperations operations + :vartype sign_in_settings: azure.mgmt.apimanagement.aio.operations.SignInSettingsOperations + :ivar sign_up_settings: SignUpSettingsOperations operations + :vartype sign_up_settings: azure.mgmt.apimanagement.aio.operations.SignUpSettingsOperations + :ivar delegation_settings: DelegationSettingsOperations operations + :vartype delegation_settings: azure.mgmt.apimanagement.aio.operations.DelegationSettingsOperations + :ivar product: ProductOperations operations + :vartype product: azure.mgmt.apimanagement.aio.operations.ProductOperations + :ivar product_api: ProductApiOperations operations + :vartype product_api: azure.mgmt.apimanagement.aio.operations.ProductApiOperations + :ivar product_group: ProductGroupOperations operations + :vartype product_group: azure.mgmt.apimanagement.aio.operations.ProductGroupOperations + :ivar product_subscriptions: ProductSubscriptionsOperations operations + :vartype product_subscriptions: azure.mgmt.apimanagement.aio.operations.ProductSubscriptionsOperations + :ivar product_policy: ProductPolicyOperations operations + :vartype product_policy: azure.mgmt.apimanagement.aio.operations.ProductPolicyOperations + :ivar quota_by_counter_keys: QuotaByCounterKeysOperations operations + :vartype quota_by_counter_keys: azure.mgmt.apimanagement.aio.operations.QuotaByCounterKeysOperations + :ivar quota_by_period_keys: QuotaByPeriodKeysOperations operations + :vartype quota_by_period_keys: azure.mgmt.apimanagement.aio.operations.QuotaByPeriodKeysOperations + :ivar region: RegionOperations operations + :vartype region: azure.mgmt.apimanagement.aio.operations.RegionOperations + :ivar reports: ReportsOperations operations + :vartype reports: azure.mgmt.apimanagement.aio.operations.ReportsOperations + :ivar subscription: SubscriptionOperations operations + :vartype subscription: azure.mgmt.apimanagement.aio.operations.SubscriptionOperations + :ivar tag_resource: TagResourceOperations operations + :vartype tag_resource: azure.mgmt.apimanagement.aio.operations.TagResourceOperations + :ivar tenant_access: TenantAccessOperations operations + :vartype tenant_access: azure.mgmt.apimanagement.aio.operations.TenantAccessOperations + :ivar tenant_access_git: TenantAccessGitOperations operations + :vartype tenant_access_git: azure.mgmt.apimanagement.aio.operations.TenantAccessGitOperations + :ivar tenant_configuration: TenantConfigurationOperations operations + :vartype tenant_configuration: azure.mgmt.apimanagement.aio.operations.TenantConfigurationOperations + :ivar user: UserOperations operations + :vartype user: azure.mgmt.apimanagement.aio.operations.UserOperations + :ivar user_group: UserGroupOperations operations + :vartype user_group: azure.mgmt.apimanagement.aio.operations.UserGroupOperations + :ivar user_subscription: UserSubscriptionOperations operations + :vartype user_subscription: azure.mgmt.apimanagement.aio.operations.UserSubscriptionOperations + :ivar user_identities: UserIdentitiesOperations operations + :vartype user_identities: azure.mgmt.apimanagement.aio.operations.UserIdentitiesOperations + :ivar user_confirmation_password: UserConfirmationPasswordOperations operations + :vartype user_confirmation_password: azure.mgmt.apimanagement.aio.operations.UserConfirmationPasswordOperations + :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 str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = ApiManagementClientConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.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_type_content_item = ContentTypeContentItemOperations( + 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.group = GroupOperations( + self._client, self._config, self._serialize, self._deserialize) + self.group_user = GroupUserOperations( + self._client, self._config, self._serialize, self._deserialize) + self.identity_provider = IdentityProviderOperations( + self._client, self._config, self._serialize, self._deserialize) + self.issue = IssueOperations( + self._client, self._config, self._serialize, self._deserialize) + self.logger = LoggerOperations( + self._client, self._config, self._serialize, self._deserialize) + self.named_value = NamedValueOperations( + self._client, self._config, self._serialize, self._deserialize) + self.network_status = NetworkStatusOperations( + self._client, self._config, self._serialize, self._deserialize) + self.notification = NotificationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_user = NotificationRecipientUserOperations( + self._client, self._config, self._serialize, self._deserialize) + self.notification_recipient_email = NotificationRecipientEmailOperations( + self._client, self._config, self._serialize, self._deserialize) + self.open_id_connect_provider = OpenIdConnectProviderOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy = PolicyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.policy_description = PolicyDescriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sign_in_settings = SignInSettingsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.sign_up_settings = SignUpSettingsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.delegation_settings = DelegationSettingsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.product = ProductOperations( + self._client, self._config, self._serialize, self._deserialize) + self.product_api = ProductApiOperations( + self._client, self._config, self._serialize, self._deserialize) + self.product_group = ProductGroupOperations( + self._client, self._config, self._serialize, self._deserialize) + self.product_subscriptions = ProductSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.product_policy = ProductPolicyOperations( + self._client, self._config, self._serialize, self._deserialize) + self.quota_by_counter_keys = QuotaByCounterKeysOperations( + self._client, self._config, self._serialize, self._deserialize) + self.quota_by_period_keys = QuotaByPeriodKeysOperations( + self._client, self._config, self._serialize, self._deserialize) + self.region = RegionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.reports = ReportsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.subscription = SubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tag_resource = TagResourceOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant_access = TenantAccessOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant_access_git = TenantAccessGitOperations( + self._client, self._config, self._serialize, self._deserialize) + self.tenant_configuration = TenantConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.user = UserOperations( + self._client, self._config, self._serialize, self._deserialize) + self.user_group = UserGroupOperations( + self._client, self._config, self._serialize, self._deserialize) + self.user_subscription = UserSubscriptionOperations( + self._client, self._config, self._serialize, self._deserialize) + self.user_identities = UserIdentitiesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.user_confirmation_password = UserConfirmationPasswordOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "ApiManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) 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 new file mode 100644 index 000000000000..0ecefbb90121 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ApiManagementClientConfiguration(Configuration): + """Configuration for ApiManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(ApiManagementClientConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-06-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-apimanagement/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) 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 new file mode 100644 index 000000000000..60aa39dc2ad2 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/__init__.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._api_operations import ApiOperations +from ._api_revision_operations import ApiRevisionOperations +from ._api_release_operations import ApiReleaseOperations +from ._api_operation_operations import ApiOperationOperations +from ._api_operation_policy_operations import ApiOperationPolicyOperations +from ._tag_operations import TagOperations +from ._api_product_operations import ApiProductOperations +from ._api_policy_operations import ApiPolicyOperations +from ._api_schema_operations import ApiSchemaOperations +from ._api_diagnostic_operations import ApiDiagnosticOperations +from ._api_issue_operations import ApiIssueOperations +from ._api_issue_comment_operations import ApiIssueCommentOperations +from ._api_issue_attachment_operations import ApiIssueAttachmentOperations +from ._api_tag_description_operations import ApiTagDescriptionOperations +from ._operation_operations import OperationOperations +from ._api_export_operations import ApiExportOperations +from ._api_version_set_operations import ApiVersionSetOperations +from ._authorization_server_operations import AuthorizationServerOperations +from ._backend_operations import BackendOperations +from ._cache_operations import CacheOperations +from ._certificate_operations import CertificateOperations +from ._content_type_operations import ContentTypeOperations +from ._content_type_content_item_operations import ContentTypeContentItemOperations +from ._deleted_services_operations import DeletedServicesOperations +from ._api_management_operations_operations import ApiManagementOperationsOperations +from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations +from ._api_management_service_operations import ApiManagementServiceOperations +from ._diagnostic_operations import DiagnosticOperations +from ._email_template_operations import EmailTemplateOperations +from ._gateway_operations import GatewayOperations +from ._gateway_hostname_configuration_operations import GatewayHostnameConfigurationOperations +from ._gateway_api_operations import GatewayApiOperations +from ._group_operations import GroupOperations +from ._group_user_operations import GroupUserOperations +from ._identity_provider_operations import IdentityProviderOperations +from ._issue_operations import IssueOperations +from ._logger_operations import LoggerOperations +from ._named_value_operations import NamedValueOperations +from ._network_status_operations import NetworkStatusOperations +from ._notification_operations import NotificationOperations +from ._notification_recipient_user_operations import NotificationRecipientUserOperations +from ._notification_recipient_email_operations import NotificationRecipientEmailOperations +from ._open_id_connect_provider_operations import OpenIdConnectProviderOperations +from ._policy_operations import PolicyOperations +from ._policy_description_operations import PolicyDescriptionOperations +from ._sign_in_settings_operations import SignInSettingsOperations +from ._sign_up_settings_operations import SignUpSettingsOperations +from ._delegation_settings_operations import DelegationSettingsOperations +from ._product_operations import ProductOperations +from ._product_api_operations import ProductApiOperations +from ._product_group_operations import ProductGroupOperations +from ._product_subscriptions_operations import ProductSubscriptionsOperations +from ._product_policy_operations import ProductPolicyOperations +from ._quota_by_counter_keys_operations import QuotaByCounterKeysOperations +from ._quota_by_period_keys_operations import QuotaByPeriodKeysOperations +from ._region_operations import RegionOperations +from ._reports_operations import ReportsOperations +from ._subscription_operations import SubscriptionOperations +from ._tag_resource_operations import TagResourceOperations +from ._tenant_access_operations import TenantAccessOperations +from ._tenant_access_git_operations import TenantAccessGitOperations +from ._tenant_configuration_operations import TenantConfigurationOperations +from ._user_operations import UserOperations +from ._user_group_operations import UserGroupOperations +from ._user_subscription_operations import UserSubscriptionOperations +from ._user_identities_operations import UserIdentitiesOperations +from ._user_confirmation_password_operations import UserConfirmationPasswordOperations + +__all__ = [ + 'ApiOperations', + 'ApiRevisionOperations', + 'ApiReleaseOperations', + 'ApiOperationOperations', + 'ApiOperationPolicyOperations', + 'TagOperations', + 'ApiProductOperations', + 'ApiPolicyOperations', + 'ApiSchemaOperations', + 'ApiDiagnosticOperations', + 'ApiIssueOperations', + 'ApiIssueCommentOperations', + 'ApiIssueAttachmentOperations', + 'ApiTagDescriptionOperations', + 'OperationOperations', + 'ApiExportOperations', + 'ApiVersionSetOperations', + 'AuthorizationServerOperations', + 'BackendOperations', + 'CacheOperations', + 'CertificateOperations', + 'ContentTypeOperations', + 'ContentTypeContentItemOperations', + 'DeletedServicesOperations', + 'ApiManagementOperationsOperations', + 'ApiManagementServiceSkusOperations', + 'ApiManagementServiceOperations', + 'DiagnosticOperations', + 'EmailTemplateOperations', + 'GatewayOperations', + 'GatewayHostnameConfigurationOperations', + 'GatewayApiOperations', + 'GroupOperations', + 'GroupUserOperations', + 'IdentityProviderOperations', + 'IssueOperations', + 'LoggerOperations', + 'NamedValueOperations', + 'NetworkStatusOperations', + 'NotificationOperations', + 'NotificationRecipientUserOperations', + 'NotificationRecipientEmailOperations', + 'OpenIdConnectProviderOperations', + 'PolicyOperations', + 'PolicyDescriptionOperations', + 'SignInSettingsOperations', + 'SignUpSettingsOperations', + 'DelegationSettingsOperations', + 'ProductOperations', + 'ProductApiOperations', + 'ProductGroupOperations', + 'ProductSubscriptionsOperations', + 'ProductPolicyOperations', + 'QuotaByCounterKeysOperations', + 'QuotaByPeriodKeysOperations', + 'RegionOperations', + 'ReportsOperations', + 'SubscriptionOperations', + 'TagResourceOperations', + 'TenantAccessOperations', + 'TenantAccessGitOperations', + 'TenantConfigurationOperations', + 'UserOperations', + 'UserGroupOperations', + 'UserSubscriptionOperations', + 'UserIdentitiesOperations', + 'UserConfirmationPasswordOperations', +] 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 new file mode 100644 index 000000000000..31144cac2189 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_diagnostic_operations.py @@ -0,0 +1,519 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.DiagnosticCollection"]: + """Lists all diagnostics of an API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + parameters: "models.DiagnosticContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.DiagnosticContract": + """Creates a new Diagnostic for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + if_match: str, + parameters: "models.DiagnosticContract", + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Diagnostic Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + diagnostic_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified Diagnostic from an API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py new file mode 100644 index 000000000000..67981d1ef856 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_export_operations.py @@ -0,0 +1,115 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + format: Union[str, "models.ExportFormat"], + export: Union[str, "models.ExportApi"], + **kwargs + ) -> "models.ApiExportResult": + """Gets the details of the API specified by its identifier in the format specified to the Storage + Blob with SAS Key valid for 5 minutes. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param format: Format in which to export the Api Details to the Storage Blob with Sas Key valid + for 5 minutes. + :type format: str or ~azure.mgmt.apimanagement.models.ExportFormat + :param export: Query parameter required to export the API details. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['format'] = self._serialize.query("format", format, 'str') + query_parameters['export'] = self._serialize.query("export", export, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiExportResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore 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 new file mode 100644 index 000000000000..2ba490bc0936 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_attachment_operations.py @@ -0,0 +1,463 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.IssueAttachmentCollection"]: + """Lists all attachments for the Issue associated with the specified API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IssueAttachmentCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueAttachmentCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('IssueAttachmentCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the issue Attachment for an API specified by its + identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. + :type attachment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + parameters: "models.IssueAttachmentContract", + if_match: Optional[str] = None, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. + :type attachment_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IssueAttachmentContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + attachment_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified comment from an Issue. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. + :type attachment_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py new file mode 100644 index 000000000000..bc849dbbc61c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_comment_operations.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.IssueCommentCollection"]: + """Lists all comments for the Issue associated with the specified API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IssueCommentCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IssueCommentCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCommentCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCommentCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the issue Comment for an API specified by its + identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + :type comment_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + parameters: "models.IssueCommentContract", + if_match: Optional[str] = None, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :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: ~azure.mgmt.apimanagement.models.IssueCommentContract + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueCommentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCommentContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IssueCommentContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + comment_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified comment from an Issue. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. + :type comment_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py new file mode 100644 index 000000000000..576f59e4e207 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_issue_operations.py @@ -0,0 +1,531 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + expand_comments_attachments: Optional[bool] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.IssueCollection"]: + """Lists all issues associated with the specified API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | + filter | eq | |
. + :type filter: str + :param expand_comments_attachments: Expand the comment attachments. + :type expand_comments_attachments: bool + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IssueCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if expand_comments_attachments is not None: + query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Issue for an API specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + expand_comments_attachments: Optional[bool] = None, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if expand_comments_attachments is not None: + query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + parameters: "models.IssueContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.IssueContract": + """Creates a new Issue for an API or updates an existing one. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IssueContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + if_match: str, + parameters: "models.IssueUpdateContract", + **kwargs + ) -> "models.IssueContract": + """Updates an existing issue for an API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IssueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + issue_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified Issue from an API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :type issue_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py new file mode 100644 index 000000000000..7178e9dbbbcc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_operations_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> 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[~azure.mgmt.apimanagement.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + 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 new file mode 100644 index 000000000000..0ebbf7094446 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_operations.py @@ -0,0 +1,1091 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _restore_initial( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceBackupRestoreParameters", + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._restore_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + + async def begin_restore( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceBackupRestoreParameters", + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a long running operation and could take several + minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param parameters: Parameters supplied to the Restore API Management service from backup + operation. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._restore_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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", + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._backup_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + + async def begin_backup( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceBackupRestoreParameters", + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Creates a backup of the API Management service to the given Azure Storage Account. This is long + running operation and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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: ~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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._backup_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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", + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceResource", + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Creates or updates an API Management service. This is long running operation and could take + several minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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: ~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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceUpdateParameters", + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + service_name: str, + parameters: "models.ApiManagementServiceUpdateParameters", + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Updates an existing API Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.ApiManagementServiceResource": + """Gets an API Management service resource description. + + :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: ApiManagementServiceResource, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + async def begin_delete( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Deletes an existing API Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> AsyncIterable["models.ApiManagementServiceListResult"]: + """List all API Management services within a resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiManagementServiceListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore + + def list( + self, + **kwargs + ) -> 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[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore + + async def get_sso_token( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "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. + :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: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceGetSsoTokenResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_sso_token.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore + + async def check_name_availability( + self, + name: str, + **kwargs + ) -> "models.ApiManagementServiceNameAvailabilityResult": + """Checks availability and correctness of a name for an API Management service. + + :param name: The name to check for availability. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiManagementServiceNameAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceNameAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiManagementServiceCheckNameAvailabilityParameters(name=name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore + + async def _apply_network_configuration_updates_initial( + self, + resource_group_name: str, + service_name: str, + location: Optional[str] = None, + **kwargs + ) -> Optional["models.ApiManagementServiceResource"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiManagementServiceApplyNetworkConfigurationParameters(location=location) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._apply_network_configuration_updates_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + + async def begin_apply_network_configuration_updates( + self, + resource_group_name: str, + service_name: str, + location: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["models.ApiManagementServiceResource"]: + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + network 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 location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. + :type location: str + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._apply_network_configuration_updates_initial( + resource_group_name=resource_group_name, + service_name=service_name, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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 new file mode 100644 index 000000000000..ca5a24d926bd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_management_service_skus_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_available_service_skus( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> AsyncIterable["models.ResourceSkuResults"]: + """Gets available SKUs for API Management service. + + Gets all available SKU for a given API Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceSkuResults or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ResourceSkuResults] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkuResults"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_available_service_skus.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkuResults', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + 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_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py new file mode 100644 index 000000000000..1f24cef5e66b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_operations.py @@ -0,0 +1,535 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.OperationCollection"]: + """Lists a collection of the operations for the specified API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param tags: Include tags in the response. + :type tags: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OperationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if tags is not None: + query_parameters['tags'] = self._serialize.query("tags", tags, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the API operation specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + **kwargs + ) -> "models.OperationContract": + """Gets the details of the API Operation 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + parameters: "models.OperationContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.OperationContract": + """Creates a new operation in the API or updates an existing one. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'OperationContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + if_match: str, + parameters: "models.OperationUpdateContract", + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: API Operation Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'OperationUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified operation in the API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py new file mode 100644 index 000000000000..f73730188d31 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operation_policy_operations.py @@ -0,0 +1,438 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + **kwargs + ) -> "models.PolicyCollection": + """Get the list of policy configuration at the API Operation level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "models.PolicyIdName"], + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the API operation policy specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "models.PolicyIdName"], + format: Optional[Union[str, "models.PolicyExportFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Get the policy configuration at the API Operation level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if format is not None: + query_parameters['format'] = self._serialize.query("format", format, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: Optional[str] = None, + value: Optional[str] = None, + format: Optional[Union[str, "models.PolicyContentFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Creates or updates policy configuration for the API Operation level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param value: Contents of the Policy as defined by the format. + :type value: str + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: str, + **kwargs + ) -> None: + """Deletes the policy configuration at the Api Operation. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param policy_id: The identifier of the Policy. + :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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py new file mode 100644 index 000000000000..bcb4cebe9ac5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_operations.py @@ -0,0 +1,685 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + tags: Optional[str] = None, + expand_api_version_set: Optional[bool] = None, + **kwargs + ) -> AsyncIterable["models.ApiCollection"]: + """Lists all APIs of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| isCurrent | filter | eq, ne | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param tags: Include tags in the response. + :type tags: str + :param expand_api_version_set: Include full ApiVersionSet resource in response. + :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[~azure.mgmt.apimanagement.models.ApiCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if tags is not None: + query_parameters['tags'] = self._serialize.query("tags", tags, 'str') + if expand_api_version_set is not None: + query_parameters['expandApiVersionSet'] = self._serialize.query("expand_api_version_set", expand_api_version_set, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the API 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + **kwargs + ) -> "models.ApiContract": + """Gets the details of the API 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json, application/vnd.swagger.doc+json, application/vnd.oai.openapi+json, application/vnd.sun.wadl+xml, application/wsdl+xml" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: "models.ApiCreateOrUpdateParameter", + if_match: Optional[str] = None, + **kwargs + ) -> Optional["models.ApiContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + parameters: "models.ApiCreateOrUpdateParameter", + if_match: Optional[str] = None, + **kwargs + ) -> 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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param parameters: Create or update parameters. + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ApiContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + parameters: "models.ApiUpdateContract", + **kwargs + ) -> "models.ApiContract": + """Updates the specified API of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param if_match: ETag of 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: API Update Contract parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + if_match: str, + delete_revisions: Optional[bool] = None, + **kwargs + ) -> None: + """Deletes the specified API of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param if_match: ETag of 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. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if delete_revisions is not None: + query_parameters['deleteRevisions'] = self._serialize.query("delete_revisions", delete_revisions, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_apis: Optional[bool] = None, + **kwargs + ) -> AsyncIterable["models.TagResourceCollection"]: + """Lists a collection of apis associated with tags. + + :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 + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| isCurrent | filter | eq | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param include_not_tagged_apis: Include not tagged APIs. + :type include_not_tagged_apis: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagResourceCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_tags.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if include_not_tagged_apis is not None: + query_parameters['includeNotTaggedApis'] = self._serialize.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + 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 new file mode 100644 index 000000000000..9d1fba58d0fc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_policy_operations.py @@ -0,0 +1,418 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + **kwargs + ) -> "models.PolicyCollection": + """Get the policy configuration at the API level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "models.PolicyIdName"], + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the API policy specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "models.PolicyIdName"], + format: Optional[Union[str, "models.PolicyExportFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Get the policy configuration at the API level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if format is not None: + query_parameters['format'] = self._serialize.query("format", format, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: Optional[str] = None, + value: Optional[str] = None, + format: Optional[Union[str, "models.PolicyContentFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Creates or updates policy configuration for the API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param value: Contents of the Policy as defined by the format. + :type value: str + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: str, + **kwargs + ) -> None: + """Deletes the policy configuration at the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param policy_id: The identifier of the Policy. + :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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py new file mode 100644 index 000000000000..7abf9437bf06 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_product_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_apis( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ProductCollection"]: + """Lists all Products, which the API is part of. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_apis.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + 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 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 new file mode 100644 index 000000000000..6968da9e807c --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_release_operations.py @@ -0,0 +1,531 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> 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. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiReleaseCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiReleaseCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiReleaseCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + **kwargs + ) -> bool: + """Returns the etag of an API release. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. + :type release_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + **kwargs + ) -> "models.ApiReleaseContract": + """Returns the details of an API release. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + if_match: Optional[str] = None, + api_release_contract_properties_api_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ) -> "models.ApiReleaseContract": + """Creates a new Release for the API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. + :type release_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param api_release_contract_properties_api_id: Identifier of the API the release belongs to. + :type api_release_contract_properties_api_id: str + :param notes: Release Notes. + :type notes: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiReleaseContract(api_id=api_release_contract_properties_api_id, notes=notes) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiReleaseContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + if_match: str, + api_release_contract_properties_api_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param api_release_contract_properties_api_id: Identifier of the API the release belongs to. + :type api_release_contract_properties_api_id: str + :param notes: Release Notes. + :type notes: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiReleaseContract(api_id=api_release_contract_properties_api_id, notes=notes) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiReleaseContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + release_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified release in the API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. + :type release_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py new file mode 100644 index 000000000000..8c1d7a2f3765 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_revision_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ApiRevisionCollection"]: + """Lists all revisions of an API. + + :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 api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiRevisionCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiRevisionCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiRevisionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiRevisionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/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 new file mode 100644 index 000000000000..18e275ffe9e0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_schema_operations.py @@ -0,0 +1,510 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.SchemaCollection"]: + """Get the schema configuration at the API level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SchemaCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SchemaCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the schema specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. + :type schema_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :rtype: bool + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + **kwargs + ) -> "models.SchemaContract": + """Get the schema configuration at the API level. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: "models.SchemaContract", + if_match: Optional[str] = None, + **kwargs + ) -> Optional["models.SchemaContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.SchemaContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'SchemaContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + parameters: "models.SchemaContract", + if_match: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["models.SchemaContract"]: + """Creates or updates schema configuration for the API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. + :type schema_id: str + :param parameters: The schema contents to apply. + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SchemaContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SchemaContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + schema_id: str, + if_match: str, + force: Optional[bool] = None, + **kwargs + ) -> None: + """Deletes the schema configuration at the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. + :type schema_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param force: If true removes all references to the schema before deleting it. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if force is not None: + query_parameters['force'] = self._serialize.query("force", force, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py new file mode 100644 index 000000000000..2c53e6cbb600 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_tag_description_operations.py @@ -0,0 +1,443 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> 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. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param 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 |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagDescriptionCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagDescriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDescriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagDescriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + **kwargs + ) -> bool: + """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. + :type tag_description_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + **kwargs + ) -> "models.TagDescriptionContract": + """Get Tag description in scope of API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + parameters: "models.TagDescriptionCreateParameters", + if_match: Optional[str] = None, + **kwargs + ) -> "models.TagDescriptionContract": + """Create/Update tag description in scope of the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. + :type tag_description_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'TagDescriptionCreateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_description_id: str, + if_match: str, + **kwargs + ) -> None: + """Delete tag description for the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. + :type tag_description_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py new file mode 100644 index 000000000000..0cddc105d6cf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_api_version_set_operations.py @@ -0,0 +1,494 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> 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. + :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 |
|-------------|-------------|-------------|-------------|
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiVersionSetCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiVersionSetCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiVersionSetCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Api Version Set specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. + :type version_set_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + **kwargs + ) -> "models.ApiVersionSetContract": + """Gets the details of the Api Version Set 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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + parameters: "models.ApiVersionSetContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.ApiVersionSetContract": + """Creates or Updates a Api Version Set. + + :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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. + :type version_set_id: str + :param parameters: Create or update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiVersionSetContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + if_match: str, + parameters: "models.ApiVersionSetUpdateParameters", + **kwargs + ) -> "models.ApiVersionSetContract": + """Updates the details of the Api VersionSet 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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + version_set_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific Api Version Set. + + :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 version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. + :type version_set_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py new file mode 100644 index 000000000000..9af3b49cf44d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_authorization_server_operations.py @@ -0,0 +1,557 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.AuthorizationServerCollection"]: + """Lists a collection of authorization servers 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 + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationServerCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AuthorizationServerCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AuthorizationServerCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + authsid: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the authorizationServer 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 authsid: Identifier of the authorization server. + :type authsid: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + authsid: str, + **kwargs + ) -> "models.AuthorizationServerContract": + """Gets the details of the authorization server 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 authsid: Identifier of the authorization server. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + parameters: "models.AuthorizationServerContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.AuthorizationServerContract": + """Creates new authorization server or updates an existing authorization server. + + :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 authsid: Identifier of the authorization server. + :type authsid: str + :param parameters: Create or update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'AuthorizationServerContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + authsid: str, + if_match: str, + parameters: "models.AuthorizationServerUpdateContract", + **kwargs + ) -> "models.AuthorizationServerContract": + """Updates the details of the authorization server 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 authsid: Identifier of the authorization server. + :type authsid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: OAuth2 Server settings Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + authsid: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific authorization server 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 authsid: Identifier of the authorization server. + :type authsid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/authorizationServers/{authsid}'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + authsid: str, + **kwargs + ) -> "models.AuthorizationServerSecretsContract": + """Gets the client secret details of the authorization server. + + :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 authsid: Identifier of the authorization server. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py new file mode 100644 index 000000000000..3b64fb66acb5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_backend_operations.py @@ -0,0 +1,574 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.BackendCollection"]: + """Lists a collection of backends 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BackendCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.BackendCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BackendCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('BackendCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the backend 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :type backend_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + **kwargs + ) -> "models.BackendContract": + """Gets the details of the backend 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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + parameters: "models.BackendContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.BackendContract": + """Creates or Updates a backend. + + :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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :type backend_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BackendContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + if_match: str, + parameters: "models.BackendUpdateParameters", + **kwargs + ) -> "models.BackendContract": + """Updates an existing backend. + + :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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'BackendUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified backend. + + :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 backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :type backend_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/backends/{backendId}'} # type: ignore + + async def reconnect( + self, + resource_group_name: str, + service_name: str, + backend_id: str, + after: Optional[datetime.timedelta] = None, + **kwargs + ) -> None: + """Notifies the APIM proxy to create a new connection to the backend after the specified timeout. + If no timeout was specified, timeout of 2 minutes is used. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. + :type backend_id: str + :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + duration of the Reconnect is PT2M. + :type after: ~datetime.timedelta + :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', {})) + + _parameters = models.BackendReconnectContract(after=after) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.reconnect.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'BackendReconnectContract') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py new file mode 100644 index 000000000000..f865dbfc404e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_cache_operations.py @@ -0,0 +1,488 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> 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. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CacheCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CacheCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). + :type cache_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + **kwargs + ) -> "models.CacheContract": + """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + parameters: "models.CacheContract", + if_match: Optional[str] = None, + **kwargs + ) -> "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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). + :type cache_id: str + :param parameters: Create or Update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'CacheContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + if_match: str, + parameters: "models.CacheUpdateParameters", + **kwargs + ) -> "models.CacheContract": + """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). + :type cache_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'CacheUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + cache_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific Cache. + + :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 cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). + :type cache_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py new file mode 100644 index 000000000000..ddc5abf8ac8e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_certificate_operations.py @@ -0,0 +1,419 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.CertificateCollection"]: + """Lists a collection of all certificates 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CertificateCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.CertificateCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CertificateCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CertificateCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the certificate 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. + :type certificate_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + **kwargs + ) -> "models.CertificateContract": + """Gets the details of the certificate 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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + parameters: "models.CertificateCreateOrUpdateParameters", + if_match: Optional[str] = None, + **kwargs + ) -> "models.CertificateContract": + """Creates or updates the certificate being used for authentication with the backend. + + :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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. + :type certificate_id: str + :param parameters: Create or Update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + certificate_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific certificate. + + :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 certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. + :type certificate_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/certificates/{certificateId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_content_item_operations.py new file mode 100644 index 000000000000..7e03b6f6dccd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_content_item_operations.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ContentTypeContentItemOperations: + """ContentTypeContentItemOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + **kwargs + ) -> AsyncIterable["models.ContentItemCollection"]: + """Returns list of content items. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ContentItemCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentItemCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ContentItemCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + **kwargs + ) -> bool: + """Returns content item metadata. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :type content_item_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + **kwargs + ) -> "models.ContentItemContract": + """Returns content item details. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + if_match: Optional[str] = None, + **kwargs + ) -> "models.ContentItemContract": + """Creates new content item. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + content_item_id: str, + if_match: str, + **kwargs + ) -> None: + """Removes specified content item. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :type content_item_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py new file mode 100644 index 000000000000..59463f6677bc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_content_type_operations.py @@ -0,0 +1,323 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> AsyncIterable["models.ContentTypeCollection"]: + """Returns list of content types. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ContentTypeCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentTypeCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ContentTypeCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + **kwargs + ) -> "models.ContentTypeContract": + """Gets API Management content type details. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContentTypeContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentTypeContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + if_match: Optional[str] = None, + **kwargs + ) -> "models.ContentTypeContract": + """Creates or updates an Content Type. + + :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 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. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContentTypeContract, or the result of cls(response) + :rtype: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + content_type_id: str, + if_match: str, + **kwargs + ) -> None: + """Removes specified content type. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py new file mode 100644 index 000000000000..2f696982bcb9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_delegation_settings_operations.py @@ -0,0 +1,363 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the DelegationSettings. + + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.PortalDelegationSettings": + """Get Delegation Settings for the Portal. + + :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: PortalDelegationSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalDelegationSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + if_match: str, + parameters: "models.PortalDelegationSettings", + **kwargs + ) -> None: + """Update Delegation 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 if_match: ETag of 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 Delegation settings. + :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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PortalDelegationSettings') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + parameters: "models.PortalDelegationSettings", + if_match: Optional[str] = None, + **kwargs + ) -> "models.PortalDelegationSettings": + """Create or Update Delegation 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 parameters: Create or update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'PortalDelegationSettings') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.PortalSettingValidationKeyContract": + """Gets the secret validation key of the DelegationSettings. + + :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: PortalSettingValidationKeyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSettingValidationKeyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} # type: ignore 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 new file mode 100644 index 000000000000..9ba3f4153c0d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_deleted_services_operations.py @@ -0,0 +1,229 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_subscription( + self, + **kwargs + ) -> 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[~azure.mgmt.apimanagement.models.DeletedServicesCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeletedServicesCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DeletedServicesCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + + async def get_by_name( + self, + service_name: str, + location: str, + **kwargs + ) -> "models.DeletedServiceContract": + """Get soft-deleted Api Management Service by name. + + :param service_name: The name of the API Management service. + :type service_name: str + :param location: The location of the deleted API Management service. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_by_name.metadata['url'] # type: ignore + path_format_arguments = { + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + + async def purge( + self, + service_name: str, + location: str, + **kwargs + ) -> Optional["models.DeletedServiceContract"]: + """Purges Api Management Service (deletes it with no option to undelete). + + :param service_name: The name of the API Management service. + :type service_name: str + :param location: The location of the deleted API Management service. + :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: ~azure.mgmt.apimanagement.models.DeletedServiceContract or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DeletedServiceContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.purge.metadata['url'] # type: ignore + path_format_arguments = { + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 new file mode 100644 index 000000000000..924f6e5ddea8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_diagnostic_operations.py @@ -0,0 +1,495 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.DiagnosticCollection"]: + """Lists all diagnostics of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DiagnosticCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + **kwargs + ) -> "models.DiagnosticContract": + """Gets the details of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + parameters: "models.DiagnosticContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.DiagnosticContract": + """Creates a new Diagnostic or updates an existing one. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + if_match: str, + parameters: "models.DiagnosticContract", + **kwargs + ) -> "models.DiagnosticContract": + """Updates the details of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Diagnostic Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + diagnostic_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified Diagnostic. + + :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 diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. + :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py new file mode 100644 index 000000000000..4463f02f3e09 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_email_template_operations.py @@ -0,0 +1,487 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.EmailTemplateCollection"]: + """Gets all email templates. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EmailTemplateCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.EmailTemplateCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EmailTemplateCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('EmailTemplateCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, "models.TemplateName"], + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the email template specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'templateName': self._serialize.url("template_name", template_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, "models.TemplateName"], + **kwargs + ) -> "models.EmailTemplateContract": + """Gets the details of the email template 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 template_name: Email Template Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'templateName': self._serialize.url("template_name", template_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, "models.TemplateName"], + parameters: "models.EmailTemplateUpdateParameters", + if_match: Optional[str] = None, + **kwargs + ) -> "models.EmailTemplateContract": + """Updates an Email Template. + + :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 template_name: Email Template Name Identifier. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName + :param parameters: Email Template update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'templateName': self._serialize.url("template_name", template_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, "models.TemplateName"], + if_match: str, + parameters: "models.EmailTemplateUpdateParameters", + **kwargs + ) -> "models.EmailTemplateContract": + """Updates API Management email template. + + :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 template_name: Email Template Name Identifier. + :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: ~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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'templateName': self._serialize.url("template_name", template_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + template_name: Union[str, "models.TemplateName"], + if_match: str, + **kwargs + ) -> None: + """Reset the Email Template to default template provided by the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'templateName': self._serialize.url("template_name", template_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py new file mode 100644 index 000000000000..eea889d7e726 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_api_operations.py @@ -0,0 +1,355 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ApiCollection"]: + """Lists a collection of the APIs associated with a gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + **kwargs + ) -> bool: + """Checks that API entity specified by identifier is associated with the Gateway entity. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + **kwargs + ) -> "models.ApiContract": + """Adds an API to the specified Gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + + _parameters = models.AssociationContract() + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'AssociationContract') + else: + body_content = None + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApiContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + api_id: str, + **kwargs + ) -> None: + """Deletes the specified API from the specified Gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param api_id: API identifier. Must be unique in the current API Management service instance. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py new file mode 100644 index 000000000000..d3276e8d360e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_hostname_configuration_operations.py @@ -0,0 +1,443 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.GatewayHostnameConfigurationCollection"]: + """Lists the collection of hostname configurations for the specified gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayHostnameConfigurationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('GatewayHostnameConfigurationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + **kwargs + ) -> bool: + """Checks that hostname configuration entity specified by identifier exists for specified Gateway + entity. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. + :type hc_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + **kwargs + ) -> "models.GatewayHostnameConfigurationContract": + """Get details of a hostname 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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + parameters: "models.GatewayHostnameConfigurationContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.GatewayHostnameConfigurationContract": + """Creates of updates hostname configuration for a Gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. + :type hc_id: str + :param parameters: + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + hc_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified hostname configuration from the specified Gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. + :type hc_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py new file mode 100644 index 000000000000..ba8e973d7159 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_gateway_operations.py @@ -0,0 +1,725 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.GatewayCollection"]: + """Lists a collection of gateways registered with service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.GatewayCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('GatewayCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Gateway 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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + **kwargs + ) -> "models.GatewayContract": + """Gets the details of the Gateway 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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + if_match: Optional[str] = None, + location_data: Optional["models.ResourceLocationDataContract"] = None, + description: Optional[str] = None, + **kwargs + ) -> "models.GatewayContract": + """Creates or updates a Gateway to be used in Api Management 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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param location_data: Gateway location. + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. + :type description: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayContract(location_data=location_data, description=description) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + if_match: str, + location_data: Optional["models.ResourceLocationDataContract"] = None, + description: Optional[str] = None, + **kwargs + ) -> "models.GatewayContract": + """Updates the details of the gateway 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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param location_data: Gateway location. + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. + :type description: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayContract(location_data=location_data, description=description) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific Gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore + + async def list_keys( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + **kwargs + ) -> "models.GatewayKeysContract": + """Retrieves gateway keys. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_keys.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayKeysContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore + + async def regenerate_key( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + key_type: Union[str, "models.KeyType"], + **kwargs + ) -> None: + """Regenerates specified gateway key invalidating any tokens created with it. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param key_type: The Key being regenerated. + :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :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', {})) + + _parameters = models.GatewayKeyRegenerationRequestContract(key_type=key_type) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.regenerate_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayKeyRegenerationRequestContract') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + async def generate_token( + self, + resource_group_name: str, + service_name: str, + gateway_id: str, + key_type: Union[str, "models.KeyType"], + expiry: datetime.datetime, + **kwargs + ) -> "models.GatewayTokenContract": + """Gets the Shared Access Authorization Token for the gateway. + + :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 gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. + :type gateway_id: str + :param key_type: The Key to be used to generate gateway token. + :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayTokenContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayTokenContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayTokenRequestContract(key_type=key_type, expiry=expiry) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.generate_token.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayTokenRequestContract') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GatewayTokenContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} # type: ignore 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 new file mode 100644 index 000000000000..b0131ccfc571 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_operations.py @@ -0,0 +1,498 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.GroupCollection"]: + """Lists a collection of groups 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 + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| externalId | filter | eq | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GroupCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + group_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the group 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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + group_id: str, + **kwargs + ) -> "models.GroupContract": + """Gets the details of the group 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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + parameters: "models.GroupCreateParameters", + if_match: Optional[str] = None, + **kwargs + ) -> "models.GroupContract": + """Creates or Updates a group. + + :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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GroupCreateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + group_id: str, + if_match: str, + parameters: "models.GroupUpdateParameters", + **kwargs + ) -> "models.GroupContract": + """Updates the details of the group 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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GroupUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + group_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific group of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py new file mode 100644 index 000000000000..ecaeac3f9e8e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_group_user_operations.py @@ -0,0 +1,347 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + group_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.UserCollection"]: + """Lists a collection of user entities associated with the group. + + :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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('UserCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore + + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + group_id: str, + user_id: str, + **kwargs + ) -> bool: + """Checks that user entity specified by identifier is associated with the group entity. + + :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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.check_entity_exists.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + + async def create( + self, + resource_group_name: str, + service_name: str, + group_id: str, + user_id: str, + **kwargs + ) -> "models.UserContract": + """Add existing user to existing group. + + :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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :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: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('UserContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('UserContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + group_id: str, + user_id: str, + **kwargs + ) -> None: + """Remove existing user from existing group. + + :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 group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py new file mode 100644 index 000000000000..c5c7c74b4c40 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_identity_provider_operations.py @@ -0,0 +1,539 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> 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. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IdentityProviderList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.IdentityProviderList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IdentityProviderList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('IdentityProviderList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + **kwargs + ) -> "models.IdentityProviderContract": + """Gets the configuration details of the identity Provider configured in specified service + instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + parameters: "models.IdentityProviderCreateContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.IdentityProviderContract": + """Creates or Updates the IdentityProvider 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 identity_provider_name: Identity Provider Type identifier. + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IdentityProviderCreateContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + if_match: str, + parameters: "models.IdentityProviderUpdateParameters", + **kwargs + ) -> "models.IdentityProviderContract": + """Updates an existing IdentityProvider 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 identity_provider_name: Identity Provider Type identifier. + :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: ~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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + if_match: str, + **kwargs + ) -> None: + """Deletes the specified identity provider 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 identity_provider_name: Identity Provider Type identifier. + :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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/identityProviders/{identityProviderName}'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + identity_provider_name: Union[str, "models.IdentityProviderType"], + **kwargs + ) -> "models.ClientSecretContract": + """Gets the client secret details of the Identity 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 identity_provider_name: Identity Provider Type identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py new file mode 100644 index 000000000000..e7d8bb1cba96 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_issue_operations.py @@ -0,0 +1,205 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.IssueCollection"]: + """Lists a collection of issues 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IssueCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + issue_id: str, + **kwargs + ) -> "models.IssueContract": + """Gets API Management issue details. + + :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 issue_id: Issue identifier. Must be unique in the current API Management service + instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py new file mode 100644 index 000000000000..c574aaf6c83a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_logger_operations.py @@ -0,0 +1,493 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.LoggerCollection"]: + """Lists a collection of loggers 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LoggerCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('LoggerCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the logger 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + :type logger_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + **kwargs + ) -> "models.LoggerContract": + """Gets the details of the logger 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 logger_id: Logger identifier. Must be unique in the API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + parameters: "models.LoggerContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.LoggerContract": + """Creates or Updates a logger. + + :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 logger_id: Logger identifier. Must be unique in the API Management service instance. + :type logger_id: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LoggerContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + if_match: str, + parameters: "models.LoggerUpdateContract", + **kwargs + ) -> "models.LoggerContract": + """Updates an existing logger. + + :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 logger_id: Logger identifier. Must be unique in the API Management service instance. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'LoggerUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + logger_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified logger. + + :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 logger_id: Logger identifier. Must be unique in the API Management service instance. + :type logger_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py new file mode 100644 index 000000000000..949f4b6fdef1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_named_value_operations.py @@ -0,0 +1,680 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.NamedValueCollection"]: + """Lists a collection of named values 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 |
|-------------|-------------|-------------|-------------|
| 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 + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NamedValueCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NamedValueCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('NamedValueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the named value specified by its identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param named_value_id: Identifier of the NamedValue. + :type named_value_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + **kwargs + ) -> "models.NamedValueContract": + """Gets the details of the named value 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 named_value_id: Identifier of the NamedValue. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: "models.NamedValueCreateContract", + if_match: Optional[str] = None, + **kwargs + ) -> Optional["models.NamedValueContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.NamedValueContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'NamedValueCreateContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + parameters: "models.NamedValueCreateContract", + if_match: Optional[str] = None, + **kwargs + ) -> AsyncLROPoller["models.NamedValueContract"]: + """Creates or updates named value. + + :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 named_value_id: Identifier of the NamedValue. + :type named_value_id: str + :param parameters: Create parameters. + :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. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + if_match: str, + parameters: "models.NamedValueUpdateParameters", + **kwargs + ) -> Optional["models.NamedValueContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.NamedValueContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'NamedValueUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def begin_update( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + if_match: str, + parameters: "models.NamedValueUpdateParameters", + **kwargs + ) -> AsyncLROPoller["models.NamedValueContract"]: + """Updates the specific named value. + + :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 named_value_id: Identifier of the NamedValue. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamedValueContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + if_match=if_match, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific named value 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 named_value_id: Identifier of the NamedValue. + :type named_value_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/namedValues/{namedValueId}'} # type: ignore + + async def list_value( + self, + resource_group_name: str, + service_name: str, + named_value_id: str, + **kwargs + ) -> "models.NamedValueSecretContract": + """Gets the secret of the named value 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 named_value_id: Identifier of the NamedValue. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_value.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # type: ignore 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 new file mode 100644 index 000000000000..5f38cd51e707 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_network_status_operations.py @@ -0,0 +1,168 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, List, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> List["models.NetworkStatusContractByLocation"]: + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. + :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: list of NetworkStatusContractByLocation, or the result of cls(response) + :rtype: list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[List["models.NetworkStatusContractByLocation"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore + + async def list_by_location( + self, + resource_group_name: str, + service_name: str, + location_name: str, + **kwargs + ) -> "models.NetworkStatusContract": + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param location_name: Location in which the API Management service is deployed. This is one of + the Azure Regions like West US, East US, South Central US. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_location.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NetworkStatusContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} # type: ignore 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 new file mode 100644 index 000000000000..bfdf6177a2a0 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_operations.py @@ -0,0 +1,259 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> 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. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either NotificationCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.NotificationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NotificationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('NotificationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + **kwargs + ) -> "models.NotificationContract": + """Gets the details of the Notification 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 notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NotificationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + if_match: Optional[str] = None, + **kwargs + ) -> "models.NotificationContract": + """Create or Update API Management publisher notification. + + :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 notification_name: Notification Name Identifier. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NotificationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore 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 new file mode 100644 index 000000000000..bd0dab6b1dcf --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_email_operations.py @@ -0,0 +1,304 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_notification( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + **kwargs + ) -> "models.RecipientEmailCollection": + """Gets the list of the Notification Recipient Emails subscribed to a notification. + + :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 notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_notification.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore + + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + email: str, + **kwargs + ) -> bool: + """Determine if Notification Recipient Email subscribed to the notification. + + :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 notification_name: Notification Name Identifier. + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.check_entity_exists.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'email': self._serialize.url("email", email, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + email: str, + **kwargs + ) -> "models.RecipientEmailContract": + """Adds the Email address to the list of Recipients for the Notification. + + :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 notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'email': self._serialize.url("email", email, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + email: str, + **kwargs + ) -> None: + """Removes the email from the list of Notification. + + :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 notification_name: Notification Name Identifier. + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'email': self._serialize.url("email", email, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py new file mode 100644 index 000000000000..ad9a7ea6c96d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_notification_recipient_user_operations.py @@ -0,0 +1,304 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_notification( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + **kwargs + ) -> "models.RecipientUserCollection": + """Gets the list of the Notification Recipient User subscribed to the notification. + + :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 notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_notification.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RecipientUserCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore + + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + user_id: str, + **kwargs + ) -> bool: + """Determine if the Notification Recipient User is subscribed to the notification. + + :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 notification_name: Notification Name Identifier. + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.check_entity_exists.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + user_id: str, + **kwargs + ) -> "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. + :type resource_group_name: str + :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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('RecipientUserContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('RecipientUserContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + notification_name: Union[str, "models.NotificationName"], + user_id: str, + **kwargs + ) -> None: + """Removes the API Management user from the list of Notification. + + :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 notification_name: Notification Name Identifier. + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py new file mode 100644 index 000000000000..4f6373e325c6 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_open_id_connect_provider_operations.py @@ -0,0 +1,557 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.OpenIdConnectProviderCollection"]: + """Lists of all the OpenId Connect Providers. + + :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 + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OpenIdConnectProviderCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OpenIdConnectProviderCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + opid: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the openIdConnectProvider 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 opid: Identifier of the OpenID Connect Provider. + :type opid: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + opid: str, + **kwargs + ) -> "models.OpenidConnectProviderContract": + """Gets specific OpenID Connect Provider without secrets. + + :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 opid: Identifier of the OpenID Connect Provider. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + opid: str, + parameters: "models.OpenidConnectProviderContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.OpenidConnectProviderContract": + """Creates or updates the OpenID Connect 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 opid: Identifier of the OpenID Connect Provider. + :type opid: str + :param parameters: Create parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'OpenidConnectProviderContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + opid: str, + if_match: str, + parameters: "models.OpenidConnectProviderUpdateContract", + **kwargs + ) -> "models.OpenidConnectProviderContract": + """Updates the specific OpenID Connect 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 opid: Identifier of the OpenID Connect Provider. + :type opid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + opid: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific OpenID Connect Provider of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param opid: Identifier of the OpenID Connect Provider. + :type opid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/openidConnectProviders/{opid}'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + opid: str, + **kwargs + ) -> "models.ClientSecretContract": + """Gets the client secret details of the OpenID Connect 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 opid: Identifier of the OpenID Connect Provider. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py new file mode 100644 index 000000000000..a763f83374fb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_operation_operations.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_operations: Optional[bool] = None, + **kwargs + ) -> AsyncIterable["models.TagResourceCollection"]: + """Lists a collection of operations associated with tags. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param include_not_tagged_operations: Include not tagged Operations. + :type include_not_tagged_operations: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagResourceCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_tags.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if include_not_tagged_operations is not None: + query_parameters['includeNotTaggedOperations'] = self._serialize.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + 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 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 new file mode 100644 index 000000000000..50991f4862e5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_description_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + scope: Optional[Union[str, "models.PolicyScopeContract"]] = None, + **kwargs + ) -> "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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if scope is not None: + query_parameters['scope'] = self._serialize.query("scope", scope, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore 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 new file mode 100644 index 000000000000..5db2ce4f305e --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_policy_operations.py @@ -0,0 +1,389 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.PolicyCollection": + """Lists all the Global Policy definitions of the Api Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, "models.PolicyIdName"], + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the Global policy definition in the Api Management + service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, "models.PolicyIdName"], + format: Optional[Union[str, "models.PolicyExportFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Get the Global policy definition of the Api Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if format is not None: + query_parameters['format'] = self._serialize.query("format", format, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: Optional[str] = None, + value: Optional[str] = None, + format: Optional[Union[str, "models.PolicyContentFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Creates or updates the global policy configuration of the Api Management service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param value: Contents of the Policy as defined by the format. + :type value: str + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: str, + **kwargs + ) -> None: + """Deletes the global policy configuration of the Api Management Service. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param policy_id: The identifier of the Policy. + :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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py new file mode 100644 index 000000000000..2e79e87fc0cd --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_api_operations.py @@ -0,0 +1,350 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ApiCollection"]: + """Lists a collection of the APIs associated with a product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} # type: ignore + + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_id: str, + **kwargs + ) -> bool: + """Checks that API entity specified by identifier is associated with the Product entity. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.check_entity_exists.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_id: str, + **kwargs + ) -> "models.ApiContract": + """Adds an API to the specified product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ApiContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + api_id: str, + **kwargs + ) -> None: + """Deletes the specified API from the specified product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py new file mode 100644 index 000000000000..ae62329af0da --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_group_operations.py @@ -0,0 +1,346 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.GroupCollection"]: + """Lists the collection of developer groups associated with the specified product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| + description | filter | eq, ne | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GroupCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} # type: ignore + + async def check_entity_exists( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_id: str, + **kwargs + ) -> bool: + """Checks that Group entity specified by identifier is associated with the Product entity. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.check_entity_exists.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_id: str, + **kwargs + ) -> "models.GroupContract": + """Adds the association between the specified developer group with the specified product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('GroupContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GroupContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + group_id: str, + **kwargs + ) -> None: + """Deletes the association between the specified group and product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param group_id: Group identifier. Must be unique in the current API Management service + instance. + :type group_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py new file mode 100644 index 000000000000..32f11f631efe --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_operations.py @@ -0,0 +1,616 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + tags: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ProductCollection"]: + """Lists a collection of products 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
| groups | expand | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :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. + :type tags: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ProductCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ProductCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if expand_groups is not None: + query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') + if tags is not None: + query_parameters['tags'] = self._serialize.query("tags", tags, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ProductCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + product_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + product_id: str, + **kwargs + ) -> "models.ProductContract": + """Gets the details of the product 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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + parameters: "models.ProductContract", + if_match: Optional[str] = None, + **kwargs + ) -> "models.ProductContract": + """Creates or Updates a product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param parameters: Create or update parameters. + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ProductContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + if_match: str, + parameters: "models.ProductUpdateParameters", + **kwargs + ) -> "models.ProductContract": + """Update existing product details. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ProductUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + **kwargs + ) -> None: + """Delete product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param delete_subscriptions: Delete existing subscriptions associated with the product or not. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if delete_subscriptions is not None: + query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore + + def list_by_tags( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + include_not_tagged_products: Optional[bool] = None, + **kwargs + ) -> AsyncIterable["models.TagResourceCollection"]: + """Lists a collection of products associated with tags. + + :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 + |
| 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 |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param include_not_tagged_products: Include not tagged Products. + :type include_not_tagged_products: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagResourceCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_tags.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if include_not_tagged_products is not None: + query_parameters['includeNotTaggedProducts'] = self._serialize.query("include_not_tagged_products", include_not_tagged_products, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + 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 new file mode 100644 index 000000000000..15509eb9bcd7 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_policy_operations.py @@ -0,0 +1,413 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + **kwargs + ) -> "models.PolicyCollection": + """Get the policy configuration at the Product level. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PolicyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "models.PolicyIdName"], + **kwargs + ) -> bool: + """Get the ETag of the policy configuration at the Product level. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "models.PolicyIdName"], + format: Optional[Union[str, "models.PolicyExportFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Get the policy configuration at the Product level. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if format is not None: + query_parameters['format'] = self._serialize.query("format", format, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: Optional[str] = None, + value: Optional[str] = None, + format: Optional[Union[str, "models.PolicyContentFormat"]] = "xml", + **kwargs + ) -> "models.PolicyContract": + """Creates or updates policy configuration for the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param value: Contents of the Policy as defined by the format. + :type value: str + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + product_id: str, + policy_id: Union[str, "models.PolicyIdName"], + if_match: str, + **kwargs + ) -> None: + """Deletes the policy configuration at the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param policy_id: The identifier of the Policy. + :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 + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py new file mode 100644 index 000000000000..9cb3b29d91a5 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_product_subscriptions_operations.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.SubscriptionCollection"]: + """Lists the collection of subscriptions to the specified product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/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 new file mode 100644 index 000000000000..916af48f4e72 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_counter_keys_operations.py @@ -0,0 +1,188 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list_by_service( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + **kwargs + ) -> "models.QuotaCounterCollection": + """Lists a collection of current quota counter periods associated with the counter-key configured + in the policy on the specified service instance. The api does not support paging yet. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + **kwargs + ) -> "models.QuotaCounterCollection": + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. + :type quota_counter_key: str + :param calls_count: Number of times Counter was called. + :type calls_count: int + :param kb_transferred: Data Transferred in KiloBytes. + :type kb_transferred: float + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.QuotaCounterValueUpdateContract(calls_count=calls_count, kb_transferred=kb_transferred) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'QuotaCounterValueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore 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 new file mode 100644 index 000000000000..acf17b306554 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_quota_by_period_keys_operations.py @@ -0,0 +1,195 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + **kwargs + ) -> "models.QuotaCounterContract": + """Gets the value of the quota counter associated with the counter-key in the policy for the + specific period in service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), + 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + quota_counter_key: str, + quota_period_key: str, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + **kwargs + ) -> "models.QuotaCounterContract": + """Updates an existing quota counter value 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 quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. + :type quota_counter_key: str + :param quota_period_key: Quota period key identifier. + :type quota_period_key: str + :param calls_count: Number of times Counter was called. + :type calls_count: int + :param kb_transferred: Data Transferred in KiloBytes. + :type kb_transferred: float + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.QuotaCounterValueUpdateContract(calls_count=calls_count, kb_transferred=kb_transferred) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), + 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'QuotaCounterValueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore 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 new file mode 100644 index 000000000000..d62250eb577d --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_region_operations.py @@ -0,0 +1,117 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> AsyncIterable["models.RegionListResult"]: + """Lists all azure regions in which the service exists. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RegionListResult or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RegionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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}/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 new file mode 100644 index 000000000000..fa56bd07cfd3 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_reports_operations.py @@ -0,0 +1,857 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_api( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by API. + + :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: The filter to apply on the operation. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore + + def list_by_user( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by User. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| userId | + select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | + eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | +
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_user.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore + + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by API Operations. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore + + def list_by_product( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by Product. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq + | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | + | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | + select, orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore + + def list_by_geo( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by geography. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| country | select | | |
| region | select | | + |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | + filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq + | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| + callCountSuccess | select | | |
| callCountBlocked | select | | |
| + callCountFailed | select | | |
| callCountOther | select | | |
| + bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| + cacheMissCount | select | | |
| apiTimeAvg | select | | |
| + apiTimeMin | select | | |
| apiTimeMax | select | | |
| + serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| + serviceTimeMax | select | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_geo.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore + + def list_by_subscription( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by subscription. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | select, filter | eq | |
| productId | select, + filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess + | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| + callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | + |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | + | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | + |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore + + def list_by_time( + self, + resource_group_name: str, + service_name: str, + filter: str, + interval: datetime.timedelta, + top: Optional[int] = None, + skip: Optional[int] = None, + orderby: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.ReportCollection"]: + """Lists report records by Time. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter, select | ge, le | |
| interval | select | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | filter | eq | |
| callCountSuccess | select | | |
| + callCountBlocked | select | | |
| callCountFailed | select | | |
| + callCountOther | select | | |
| bandwidth | select, orderBy | | |
| + cacheHitsCount | select | | |
| cacheMissCount | select | | |
| + apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | + select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | + select | | |
| serviceTimeMax | select | | |
. + :type filter: str + :param interval: By time interval. Interval must be multiple of 15 minutes and may not be zero. + The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This + code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new + TimeSpan(hours, minutes, seconds)). + :type interval: ~datetime.timedelta + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param orderby: OData order by query option. + :type orderby: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_time.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if orderby is not None: + query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') + query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore + + def list_by_request( + self, + resource_group_name: str, + service_name: str, + filter: str, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.RequestReportCollection"]: + """Lists report records by Request. + + :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 |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | + |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | + filter | eq | |
| subscriptionId | filter | eq | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RequestReportCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.RequestReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RequestReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_request.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('RequestReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + 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 new file mode 100644 index 000000000000..a3ff0fdf2b56 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_in_settings_operations.py @@ -0,0 +1,308 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the SignInSettings. + + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.PortalSigninSettings": + """Get Sign In Settings for the Portal. + + :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: PortalSigninSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSigninSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + if_match: str, + enabled: Optional[bool] = None, + **kwargs + ) -> None: + """Update Sign-In 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 if_match: ETag of 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 enabled: Redirect Anonymous users to the Sign-In page. + :type enabled: 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', {})) + + _parameters = models.PortalSigninSettings(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSigninSettings') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + if_match: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs + ) -> "models.PortalSigninSettings": + """Create or Update Sign-In 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 if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param enabled: Redirect Anonymous users to the Sign-In page. + :type enabled: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSigninSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSigninSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSigninSettings(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSigninSettings') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore 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 new file mode 100644 index 000000000000..1a331b6e0fcc --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_sign_up_settings_operations.py @@ -0,0 +1,314 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the SignUpSettings. + + :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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + **kwargs + ) -> "models.PortalSignupSettings": + """Get Sign Up Settings for the Portal. + + :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: PortalSignupSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSignupSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + if_match: str, + enabled: Optional[bool] = None, + terms_of_service: Optional["models.TermsOfServiceProperties"] = None, + **kwargs + ) -> None: + """Update Sign-Up 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 if_match: ETag of 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 enabled: Allow users to sign up on a developer portal. + :type enabled: bool + :param terms_of_service: Terms of service contract properties. + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :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', {})) + + _parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSignupSettings') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + if_match: Optional[str] = None, + enabled: Optional[bool] = None, + terms_of_service: Optional["models.TermsOfServiceProperties"] = None, + **kwargs + ) -> "models.PortalSignupSettings": + """Create or Update Sign-Up 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 if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param enabled: Allow users to sign up on a developer portal. + :type enabled: bool + :param terms_of_service: Terms of service contract properties. + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSignupSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSignupSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSignupSettings') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore 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 new file mode 100644 index 000000000000..a1b393c371d1 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_subscription_operations.py @@ -0,0 +1,722 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.SubscriptionCollection"]: + """Lists all subscriptions of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + sid: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the apimanagement subscription specified by its + identifier. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + sid: str, + **kwargs + ) -> "models.SubscriptionContract": + """Gets the specified Subscription entity. + + :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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + sid: str, + parameters: "models.SubscriptionCreateParameters", + notify: Optional[bool] = None, + if_match: Optional[str] = None, + app_type: Optional[Union[str, "models.AppType"]] = None, + **kwargs + ) -> "models.SubscriptionContract": + """Creates or updates the subscription of specified user to the specified product. + + :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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :param parameters: Create parameters. + :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. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if notify is not None: + query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'SubscriptionCreateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + sid: str, + if_match: str, + parameters: "models.SubscriptionUpdateParameters", + notify: Optional[bool] = None, + app_type: Optional[Union[str, "models.AppType"]] = None, + **kwargs + ) -> "models.SubscriptionContract": + """Updates the details of a subscription 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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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. + :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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if notify is not None: + query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'SubscriptionUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + sid: str, + if_match: str, + **kwargs + ) -> None: + """Deletes the specified subscription. + + :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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/subscriptions/{sid}'} # type: ignore + + async def regenerate_primary_key( + self, + resource_group_name: str, + service_name: str, + sid: str, + **kwargs + ) -> None: + """Regenerates primary key of existing subscription of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_primary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + async def regenerate_secondary_key( + self, + resource_group_name: str, + service_name: str, + sid: str, + **kwargs + ) -> None: + """Regenerates secondary key of existing subscription of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :type sid: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_secondary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + sid: str, + **kwargs + ) -> "models.SubscriptionKeysContract": + """Gets the specified Subscription keys. + + :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 sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py new file mode 100644 index 000000000000..88915b0c8fa9 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_operations.py @@ -0,0 +1,1651 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.TagCollection"]: + """Lists all Tags associated with the Operation. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} # type: ignore + + async def get_entity_state_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + **kwargs + ) -> bool: + """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_state_by_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get_by_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Get tag associated with the Operation. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_by_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + + async def assign_to_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Assign tag to the Operation. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.assign_to_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore + + async def detach_from_operation( + self, + resource_group_name: str, + service_name: str, + api_id: str, + operation_id: str, + tag_id: str, + **kwargs + ) -> None: + """Detach the tag from the Operation. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.detach_from_operation.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + def list_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.TagCollection"]: + """Lists all Tags associated with the API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param 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 |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} # type: ignore + + async def get_entity_state_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + **kwargs + ) -> bool: + """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_state_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get_by_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Get tag associated with the API. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_by_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + + async def assign_to_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Assign tag to the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.assign_to_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore + + async def detach_from_api( + self, + resource_group_name: str, + service_name: str, + api_id: str, + tag_id: str, + **kwargs + ) -> None: + """Detach the tag from the Api. + + :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 api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. + :type api_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.detach_from_api.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + def list_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.TagCollection"]: + """Lists all Tags associated with the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} # type: ignore + + async def get_entity_state_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + tag_id: str, + **kwargs + ) -> bool: + """Gets the entity state version of the tag 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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_state_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + async def get_by_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Get tag associated with the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_by_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + + async def assign_to_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Assign tag to the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.assign_to_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TagContract', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore + + async def detach_from_product( + self, + resource_group_name: str, + service_name: str, + product_id: str, + tag_id: str, + **kwargs + ) -> None: + """Detach the tag from the Product. + + :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 product_id: Product identifier. Must be unique in the current API Management service + instance. + :type product_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.detach_from_product.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + scope: Optional[str] = None, + **kwargs + ) -> AsyncIterable["models.TagCollection"]: + """Lists a collection of tags 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 + |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. + :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[~azure.mgmt.apimanagement.models.TagCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if scope is not None: + query_parameters['scope'] = self._serialize.query("scope", scope, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore + + async def get_entity_state( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + **kwargs + ) -> bool: + """Gets the entity state version of the tag 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_state.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + **kwargs + ) -> "models.TagContract": + """Gets the details of the tag 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + if_match: Optional[str] = None, + display_name: Optional[str] = None, + **kwargs + ) -> "models.TagContract": + """Creates a tag. + + :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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :param display_name: Tag name. + :type display_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagCreateUpdateParameters(display_name=display_name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'TagCreateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + if_match: str, + display_name: Optional[str] = None, + **kwargs + ) -> "models.TagContract": + """Updates the details of the tag 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 tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param display_name: Tag name. + :type display_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagCreateUpdateParameters(display_name=display_name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'TagCreateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + tag_id: str, + if_match: str, + **kwargs + ) -> None: + """Deletes specific tag of the API Management service instance. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. + :type tag_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py new file mode 100644 index 000000000000..5bf76ddb8530 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tag_resource_operations.py @@ -0,0 +1,146 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + 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 + ) -> AsyncIterable["models.TagResourceCollection"]: + """Lists a collection of resources associated with tags. + + :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 |
|-------------|-------------|-------------|-------------|
| aid | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
| state | filter | eq | |
| isCurrent + | filter | eq | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TagResourceCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + 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}/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 new file mode 100644 index 000000000000..70eaf6b3d180 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_git_operations.py @@ -0,0 +1,291 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> "models.AccessInformationContract": + """Gets the Git access configuration for the tenant. Without secrets. + + :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 access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git'} # type: ignore + + async def regenerate_primary_key( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> None: + """Regenerate primary access key for GIT. + + :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 access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_primary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + async def regenerate_secondary_key( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> None: + """Regenerate secondary access key for GIT. + + :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 access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_secondary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> "models.AccessInformationContract": + """Gets the Git access configuration for the tenant. + + :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 access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/listSecrets'} # 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 new file mode 100644 index 000000000000..53afec8742df --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_access_operations.py @@ -0,0 +1,435 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> bool: + """Tenant access metadata. + + :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 access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> "models.AccessInformationContract": + """Get tenant access information details without secrets. + + :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 access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + if_match: str, + enabled: Optional[bool] = None, + **kwargs + ) -> "models.AccessInformationContract": + """Update tenant access information details. + + :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 access_name: The identifier of the Access configuration. + :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 enabled: Determines whether direct access is enabled. + :type enabled: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessInformationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AccessInformationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.AccessInformationUpdateParameters(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'AccessInformationUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore + + async def regenerate_primary_key( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> None: + """Regenerate primary access key. + + :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 access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_primary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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 + + async def regenerate_secondary_key( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> None: + """Regenerate secondary access key. + + :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 access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.regenerate_secondary_key.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore + + async def list_secrets( + self, + resource_group_name: str, + service_name: str, + access_name: Union[str, "models.AccessIdName"], + **kwargs + ) -> "models.AccessInformationContract": + """Get tenant access information details. + + :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 access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.list_secrets.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + 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 new file mode 100644 index 000000000000..b3611304eb15 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_tenant_configuration_operations.py @@ -0,0 +1,517 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _deploy_initial( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "models.ConfigurationIdName"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> Optional["models.OperationResultContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeployConfigurationParameters(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._deploy_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'DeployConfigurationParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + + async def begin_deploy( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "models.ConfigurationIdName"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> AsyncLROPoller["models.OperationResultContract"]: + """This operation applies changes from the specified Git branch to the configuration database. + This is a long running operation and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. + :type branch: str + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :type force: bool + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._deploy_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> Optional["models.OperationResultContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.SaveConfigurationParameter(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._save_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'SaveConfigurationParameter') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + + async def begin_save( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "models.ConfigurationIdName"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> AsyncLROPoller["models.OperationResultContract"]: + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a long running operation and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch in which to commit the current configuration + snapshot. + :type branch: str + :param force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. + :type force: bool + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._save_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> Optional["models.OperationResultContract"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeployConfigurationParameters(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._validate_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'DeployConfigurationParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + + async def begin_validate( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "models.ConfigurationIdName"], + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ) -> AsyncLROPoller["models.OperationResultContract"]: + """This operation validates the changes in the specified Git branch. This is a long running + operation and could take several minutes to complete. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. + :type branch: str + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :type force: bool + :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: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._validate_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + + async def get_sync_state( + self, + resource_group_name: str, + service_name: str, + configuration_name: Union[str, "models.ConfigurationIdName"], + **kwargs + ) -> "models.TenantConfigurationSyncStateContract": + """Gets the status of the most recent synchronization between the configuration database and the + Git repository. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :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 ~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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_sync_state.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} # type: ignore 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 new file mode 100644 index 000000000000..074ee318a46a --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_confirmation_password_operations.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def send( + self, + resource_group_name: str, + service_name: str, + user_id: str, + app_type: Optional[Union[str, "models.AppType"]] = None, + **kwargs + ) -> None: + """Sends confirmation. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :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 ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.send.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py new file mode 100644 index 000000000000..4e4f8111b959 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_group_operations.py @@ -0,0 +1,142 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.GroupCollection"]: + """Lists all user groups. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions + |
|-------------|------------------------|-----------------------------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GroupCollection or the result of cls(response) + :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"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/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 new file mode 100644 index 000000000000..30436104246b --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_identities_operations.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + **kwargs + ) -> AsyncIterable["models.UserIdentityCollection"]: + """List of all user identities. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserIdentityCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserIdentityCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserIdentityCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('UserIdentityCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/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 new file mode 100644 index 000000000000..5a64d4d681eb --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_operations.py @@ -0,0 +1,665 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import datetime +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name: str, + service_name: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + expand_groups: Optional[bool] = None, + **kwargs + ) -> AsyncIterable["models.UserCollection"]: + """Lists a collection of registered users 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 filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | + |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| groups | expand | | |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :param expand_groups: Detailed Group in response. + :type expand_groups: bool + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UserCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.UserCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + if expand_groups is not None: + query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('UserCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore + + async def get_entity_tag( + self, + resource_group_name: str, + service_name: str, + user_id: str, + **kwargs + ) -> bool: + """Gets the entity state (Etag) version of the user 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 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: 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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + + async def get( + self, + resource_group_name: str, + service_name: str, + user_id: str, + **kwargs + ) -> "models.UserContract": + """Gets the details of the user 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 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: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + parameters: "models.UserCreateParameters", + notify: Optional[bool] = None, + if_match: Optional[str] = None, + **kwargs + ) -> "models.UserContract": + """Creates or Updates a user. + + :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 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: ~azure.mgmt.apimanagement.models.UserCreateParameters + :param notify: Send an Email notification to the User. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if notify is not None: + query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'UserCreateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + + async def update( + self, + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + parameters: "models.UserUpdateParameters", + **kwargs + ) -> "models.UserContract": + """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'UserUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + service_name: str, + user_id: str, + if_match: str, + delete_subscriptions: Optional[bool] = None, + notify: Optional[bool] = None, + app_type: Optional[Union[str, "models.AppType"]] = None, + **kwargs + ) -> None: + """Deletes specific user. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :param delete_subscriptions: Whether to delete user's subscription or not. + :type delete_subscriptions: bool + :param notify: Send an Account Closed Email notification to the User. + :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 ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if delete_subscriptions is not None: + query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') + if notify is not None: + query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, 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}/users/{userId}'} # type: ignore + + async def generate_sso_url( + self, + resource_group_name: str, + service_name: str, + user_id: str, + **kwargs + ) -> "models.GenerateSsoUrlResult": + """Retrieves a redirection URL containing an authentication token for signing a given user into + the developer portal. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :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: GenerateSsoUrlResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenerateSsoUrlResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.generate_sso_url.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore + + async def get_shared_access_token( + self, + resource_group_name: str, + service_name: str, + user_id: str, + key_type: Optional[Union[str, "models.KeyType"]] = None, + expiry: Optional[datetime.datetime] = None, + **kwargs + ) -> "models.UserTokenResult": + """Gets the Shared Access Authorization Token for the User. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :param key_type: The Key to be used to generate token for user. + :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserTokenResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.UserTokenParameters(key_type=key_type, expiry=expiry) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.get_shared_access_token.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'UserTokenParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('UserTokenResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} # type: ignore 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 new file mode 100644 index 000000000000..a6d0b3230a1f --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/aio/operations/_user_subscription_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + service_name: str, + user_id: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skip: Optional[int] = None, + **kwargs + ) -> AsyncIterable["models.SubscriptionCollection"]: + """Lists the collection of subscriptions of the specified user. + + :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 user_id: User identifier. Must be unique in the current API Management service instance. + :type user_id: str + :param filter: | Field | Usage | Supported operators | Supported functions + |
|-------------|------------------------|-----------------------------------|
|name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
|displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
|stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|productId | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skip: Number of records to skip. + :type skip: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SubscriptionCollection or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skip is not None: + query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore 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 63f339e9d0f0..8d298f537a6f 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/__init__.py @@ -1,21 +1,21 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- try: from ._models_py3 import AccessInformationContract from ._models_py3 import AccessInformationUpdateParameters from ._models_py3 import AdditionalLocation + from ._models_py3 import ApiCollection from ._models_py3 import ApiContract from ._models_py3 import ApiContractProperties + from ._models_py3 import ApiContractUpdateProperties from ._models_py3 import ApiCreateOrUpdateParameter + from ._models_py3 import ApiCreateOrUpdateProperties from ._models_py3 import ApiCreateOrUpdatePropertiesWsdlSelector from ._models_py3 import ApiEntityBaseContract from ._models_py3 import ApiExportResult @@ -26,60 +26,90 @@ from ._models_py3 import ApiManagementServiceCheckNameAvailabilityParameters from ._models_py3 import ApiManagementServiceGetSsoTokenResult from ._models_py3 import ApiManagementServiceIdentity + from ._models_py3 import ApiManagementServiceListResult from ._models_py3 import ApiManagementServiceNameAvailabilityResult + from ._models_py3 import ApiManagementServiceProperties from ._models_py3 import ApiManagementServiceResource from ._models_py3 import ApiManagementServiceSkuProperties from ._models_py3 import ApiManagementServiceUpdateParameters - from ._models_py3 import ApimResource + from ._models_py3 import ApiManagementServiceUpdateProperties + from ._models_py3 import ApiReleaseCollection from ._models_py3 import ApiReleaseContract + from ._models_py3 import ApiRevisionCollection from ._models_py3 import ApiRevisionContract from ._models_py3 import ApiRevisionInfoContract from ._models_py3 import ApiTagResourceContractProperties from ._models_py3 import ApiUpdateContract from ._models_py3 import ApiVersionConstraint + from ._models_py3 import ApiVersionSetCollection from ._models_py3 import ApiVersionSetContract from ._models_py3 import ApiVersionSetContractDetails + from ._models_py3 import ApiVersionSetContractProperties from ._models_py3 import ApiVersionSetEntityBase from ._models_py3 import ApiVersionSetUpdateParameters + from ._models_py3 import ApiVersionSetUpdateParametersProperties + from ._models_py3 import ApimResource from ._models_py3 import AssociationContract from ._models_py3 import AuthenticationSettingsContract + from ._models_py3 import AuthorizationServerCollection from ._models_py3 import AuthorizationServerContract from ._models_py3 import AuthorizationServerContractBaseProperties + from ._models_py3 import AuthorizationServerContractProperties + from ._models_py3 import AuthorizationServerSecretsContract from ._models_py3 import AuthorizationServerUpdateContract + from ._models_py3 import AuthorizationServerUpdateContractProperties from ._models_py3 import BackendAuthorizationHeaderCredentials from ._models_py3 import BackendBaseParameters + from ._models_py3 import BackendCollection from ._models_py3 import BackendContract + from ._models_py3 import BackendContractProperties from ._models_py3 import BackendCredentialsContract from ._models_py3 import BackendProperties from ._models_py3 import BackendProxyContract from ._models_py3 import BackendReconnectContract from ._models_py3 import BackendServiceFabricClusterProperties from ._models_py3 import BackendTlsProperties + from ._models_py3 import BackendUpdateParameterProperties from ._models_py3 import BackendUpdateParameters from ._models_py3 import BodyDiagnosticSettings + from ._models_py3 import CacheCollection from ._models_py3 import CacheContract from ._models_py3 import CacheUpdateParameters + from ._models_py3 import CertificateCollection from ._models_py3 import CertificateConfiguration from ._models_py3 import CertificateContract from ._models_py3 import CertificateCreateOrUpdateParameters from ._models_py3 import CertificateInformation from ._models_py3 import ClientSecretContract from ._models_py3 import ConnectivityStatusContract + from ._models_py3 import ContentItemCollection + from ._models_py3 import ContentItemContract + from ._models_py3 import ContentTypeCollection + from ._models_py3 import ContentTypeContract + from ._models_py3 import DataMasking + from ._models_py3 import DataMaskingEntity + from ._models_py3 import DeletedServiceContract + from ._models_py3 import DeletedServicesCollection from ._models_py3 import DeployConfigurationParameters + from ._models_py3 import DiagnosticCollection from ._models_py3 import DiagnosticContract + from ._models_py3 import EmailTemplateCollection from ._models_py3 import EmailTemplateContract from ._models_py3 import EmailTemplateParametersContractProperties from ._models_py3 import EmailTemplateUpdateParameters from ._models_py3 import ErrorFieldContract - from ._models_py3 import ErrorResponse, ErrorResponseException + from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseBody + from ._models_py3 import GatewayCollection from ._models_py3 import GatewayContract + from ._models_py3 import GatewayHostnameConfigurationCollection from ._models_py3 import GatewayHostnameConfigurationContract from ._models_py3 import GatewayKeyRegenerationRequestContract from ._models_py3 import GatewayKeysContract from ._models_py3 import GatewayTokenContract from ._models_py3 import GatewayTokenRequestContract from ._models_py3 import GenerateSsoUrlResult + from ._models_py3 import GroupCollection from ._models_py3 import GroupContract from ._models_py3 import GroupContractProperties from ._models_py3 import GroupCreateParameters @@ -88,34 +118,58 @@ from ._models_py3 import HttpMessageDiagnostic from ._models_py3 import IdentityProviderBaseParameters from ._models_py3 import IdentityProviderContract + from ._models_py3 import IdentityProviderContractProperties from ._models_py3 import IdentityProviderCreateContract + from ._models_py3 import IdentityProviderCreateContractProperties + from ._models_py3 import IdentityProviderList from ._models_py3 import IdentityProviderUpdateParameters + from ._models_py3 import IdentityProviderUpdateProperties + from ._models_py3 import IssueAttachmentCollection from ._models_py3 import IssueAttachmentContract + from ._models_py3 import IssueCollection + from ._models_py3 import IssueCommentCollection from ._models_py3 import IssueCommentContract from ._models_py3 import IssueContract from ._models_py3 import IssueContractBaseProperties + from ._models_py3 import IssueContractProperties from ._models_py3 import IssueUpdateContract + from ._models_py3 import IssueUpdateContractProperties + from ._models_py3 import KeyVaultContractCreateProperties + from ._models_py3 import KeyVaultContractProperties + from ._models_py3 import KeyVaultLastAccessStatusContractProperties + from ._models_py3 import LoggerCollection from ._models_py3 import LoggerContract from ._models_py3 import LoggerUpdateContract + from ._models_py3 import NamedValueCollection from ._models_py3 import NamedValueContract + from ._models_py3 import NamedValueContractProperties from ._models_py3 import NamedValueCreateContract + from ._models_py3 import NamedValueCreateContractProperties from ._models_py3 import NamedValueEntityBaseParameters + from ._models_py3 import NamedValueSecretContract + from ._models_py3 import NamedValueUpdateParameterProperties from ._models_py3 import NamedValueUpdateParameters from ._models_py3 import NetworkStatusContract from ._models_py3 import NetworkStatusContractByLocation + from ._models_py3 import NotificationCollection from ._models_py3 import NotificationContract from ._models_py3 import OAuth2AuthenticationSettingsContract from ._models_py3 import OpenIdAuthenticationSettingsContract + from ._models_py3 import OpenIdConnectProviderCollection from ._models_py3 import OpenidConnectProviderContract from ._models_py3 import OpenidConnectProviderUpdateContract from ._models_py3 import Operation + from ._models_py3 import OperationCollection from ._models_py3 import OperationContract + from ._models_py3 import OperationContractProperties from ._models_py3 import OperationDisplay from ._models_py3 import OperationEntityBaseContract + from ._models_py3 import OperationListResult from ._models_py3 import OperationResultContract from ._models_py3 import OperationResultLogItemContract from ._models_py3 import OperationTagResourceContractProperties from ._models_py3 import OperationUpdateContract + from ._models_py3 import OperationUpdateContractProperties from ._models_py3 import ParameterContract from ._models_py3 import PipelineDiagnosticSettings from ._models_py3 import PolicyCollection @@ -126,318 +180,388 @@ from ._models_py3 import PortalSettingValidationKeyContract from ._models_py3 import PortalSigninSettings from ._models_py3 import PortalSignupSettings + from ._models_py3 import ProductCollection from ._models_py3 import ProductContract + from ._models_py3 import ProductContractProperties from ._models_py3 import ProductEntityBaseParameters from ._models_py3 import ProductTagResourceContractProperties from ._models_py3 import ProductUpdateParameters - from ._models_py3 import PropertyValueContract + from ._models_py3 import ProductUpdateProperties from ._models_py3 import QuotaCounterCollection from ._models_py3 import QuotaCounterContract from ._models_py3 import QuotaCounterValueContract from ._models_py3 import QuotaCounterValueContractProperties + from ._models_py3 import QuotaCounterValueUpdateContract from ._models_py3 import RecipientEmailCollection from ._models_py3 import RecipientEmailContract - from ._models_py3 import RecipientsContractProperties from ._models_py3 import RecipientUserCollection from ._models_py3 import RecipientUserContract + from ._models_py3 import RecipientsContractProperties from ._models_py3 import RegionContract + from ._models_py3 import RegionListResult from ._models_py3 import RegistrationDelegationSettingsProperties + from ._models_py3 import ReportCollection from ._models_py3 import ReportRecordContract from ._models_py3 import RepresentationContract from ._models_py3 import RequestContract + from ._models_py3 import RequestReportCollection from ._models_py3 import RequestReportRecordContract from ._models_py3 import Resource from ._models_py3 import ResourceLocationDataContract from ._models_py3 import ResourceSku from ._models_py3 import ResourceSkuCapacity from ._models_py3 import ResourceSkuResult + from ._models_py3 import ResourceSkuResults from ._models_py3 import ResponseContract from ._models_py3 import SamplingSettings from ._models_py3 import SaveConfigurationParameter + from ._models_py3 import SchemaCollection from ._models_py3 import SchemaContract + from ._models_py3 import SubscriptionCollection from ._models_py3 import SubscriptionContract from ._models_py3 import SubscriptionCreateParameters from ._models_py3 import SubscriptionKeyParameterNamesContract from ._models_py3 import SubscriptionKeysContract - from ._models_py3 import SubscriptionsDelegationSettingsProperties from ._models_py3 import SubscriptionUpdateParameters + from ._models_py3 import SubscriptionsDelegationSettingsProperties + from ._models_py3 import TagCollection from ._models_py3 import TagContract from ._models_py3 import TagCreateUpdateParameters + from ._models_py3 import TagDescriptionBaseProperties + from ._models_py3 import TagDescriptionCollection from ._models_py3 import TagDescriptionContract + from ._models_py3 import TagDescriptionContractProperties from ._models_py3 import TagDescriptionCreateParameters + from ._models_py3 import TagResourceCollection from ._models_py3 import TagResourceContract - from ._models_py3 import TagTagResourceContractProperties + from ._models_py3 import TagResourceContractProperties from ._models_py3 import TenantConfigurationSyncStateContract from ._models_py3 import TermsOfServiceProperties from ._models_py3 import TokenBodyParameterContract + from ._models_py3 import UserCollection from ._models_py3 import UserContract + from ._models_py3 import UserContractProperties + from ._models_py3 import UserCreateParameterProperties from ._models_py3 import UserCreateParameters from ._models_py3 import UserEntityBaseParameters + from ._models_py3 import UserIdentityCollection from ._models_py3 import UserIdentityContract from ._models_py3 import UserIdentityProperties from ._models_py3 import UserTokenParameters from ._models_py3 import UserTokenResult from ._models_py3 import UserUpdateParameters + from ._models_py3 import UserUpdateParametersProperties from ._models_py3 import VirtualNetworkConfiguration from ._models_py3 import X509CertificateName except (SyntaxError, ImportError): - from ._models import AccessInformationContract - from ._models import AccessInformationUpdateParameters - from ._models import AdditionalLocation - from ._models import ApiContract - from ._models import ApiContractProperties - from ._models import ApiCreateOrUpdateParameter - from ._models import ApiCreateOrUpdatePropertiesWsdlSelector - from ._models import ApiEntityBaseContract - from ._models import ApiExportResult - from ._models import ApiExportResultValue - from ._models import ApiManagementServiceApplyNetworkConfigurationParameters - from ._models import ApiManagementServiceBackupRestoreParameters - from ._models import ApiManagementServiceBaseProperties - from ._models import ApiManagementServiceCheckNameAvailabilityParameters - from ._models import ApiManagementServiceGetSsoTokenResult - from ._models import ApiManagementServiceIdentity - from ._models import ApiManagementServiceNameAvailabilityResult - from ._models import ApiManagementServiceResource - from ._models import ApiManagementServiceSkuProperties - from ._models import ApiManagementServiceUpdateParameters - from ._models import ApimResource - from ._models import ApiReleaseContract - from ._models import ApiRevisionContract - from ._models import ApiRevisionInfoContract - from ._models import ApiTagResourceContractProperties - from ._models import ApiUpdateContract - from ._models import ApiVersionConstraint - from ._models import ApiVersionSetContract - from ._models import ApiVersionSetContractDetails - from ._models import ApiVersionSetEntityBase - from ._models import ApiVersionSetUpdateParameters - from ._models import AssociationContract - from ._models import AuthenticationSettingsContract - from ._models import AuthorizationServerContract - from ._models import AuthorizationServerContractBaseProperties - from ._models import AuthorizationServerUpdateContract - from ._models import BackendAuthorizationHeaderCredentials - from ._models import BackendBaseParameters - from ._models import BackendContract - from ._models import BackendCredentialsContract - from ._models import BackendProperties - from ._models import BackendProxyContract - from ._models import BackendReconnectContract - from ._models import BackendServiceFabricClusterProperties - from ._models import BackendTlsProperties - from ._models import BackendUpdateParameters - from ._models import BodyDiagnosticSettings - from ._models import CacheContract - from ._models import CacheUpdateParameters - from ._models import CertificateConfiguration - from ._models import CertificateContract - from ._models import CertificateCreateOrUpdateParameters - from ._models import CertificateInformation - from ._models import ClientSecretContract - from ._models import ConnectivityStatusContract - from ._models import DeployConfigurationParameters - from ._models import DiagnosticContract - from ._models import EmailTemplateContract - from ._models import EmailTemplateParametersContractProperties - from ._models import EmailTemplateUpdateParameters - from ._models import ErrorFieldContract - from ._models import ErrorResponse, ErrorResponseException - from ._models import ErrorResponseBody - from ._models import GatewayContract - from ._models import GatewayHostnameConfigurationContract - from ._models import GatewayKeyRegenerationRequestContract - from ._models import GatewayKeysContract - from ._models import GatewayTokenContract - from ._models import GatewayTokenRequestContract - from ._models import GenerateSsoUrlResult - from ._models import GroupContract - from ._models import GroupContractProperties - from ._models import GroupCreateParameters - from ._models import GroupUpdateParameters - from ._models import HostnameConfiguration - from ._models import HttpMessageDiagnostic - from ._models import IdentityProviderBaseParameters - from ._models import IdentityProviderContract - from ._models import IdentityProviderCreateContract - from ._models import IdentityProviderUpdateParameters - from ._models import IssueAttachmentContract - from ._models import IssueCommentContract - from ._models import IssueContract - from ._models import IssueContractBaseProperties - from ._models import IssueUpdateContract - from ._models import LoggerContract - from ._models import LoggerUpdateContract - from ._models import NamedValueContract - from ._models import NamedValueCreateContract - from ._models import NamedValueEntityBaseParameters - from ._models import NamedValueUpdateParameters - from ._models import NetworkStatusContract - from ._models import NetworkStatusContractByLocation - from ._models import NotificationContract - from ._models import OAuth2AuthenticationSettingsContract - from ._models import OpenIdAuthenticationSettingsContract - from ._models import OpenidConnectProviderContract - from ._models import OpenidConnectProviderUpdateContract - from ._models import Operation - from ._models import OperationContract - from ._models import OperationDisplay - from ._models import OperationEntityBaseContract - from ._models import OperationResultContract - from ._models import OperationResultLogItemContract - from ._models import OperationTagResourceContractProperties - from ._models import OperationUpdateContract - from ._models import ParameterContract - from ._models import PipelineDiagnosticSettings - from ._models import PolicyCollection - from ._models import PolicyContract - from ._models import PolicyDescriptionCollection - from ._models import PolicyDescriptionContract - from ._models import PortalDelegationSettings - from ._models import PortalSettingValidationKeyContract - from ._models import PortalSigninSettings - from ._models import PortalSignupSettings - from ._models import ProductContract - from ._models import ProductEntityBaseParameters - from ._models import ProductTagResourceContractProperties - from ._models import ProductUpdateParameters - from ._models import PropertyValueContract - from ._models import QuotaCounterCollection - from ._models import QuotaCounterContract - from ._models import QuotaCounterValueContract - from ._models import QuotaCounterValueContractProperties - from ._models import RecipientEmailCollection - from ._models import RecipientEmailContract - from ._models import RecipientsContractProperties - from ._models import RecipientUserCollection - from ._models import RecipientUserContract - from ._models import RegionContract - from ._models import RegistrationDelegationSettingsProperties - from ._models import ReportRecordContract - from ._models import RepresentationContract - from ._models import RequestContract - from ._models import RequestReportRecordContract - from ._models import Resource - from ._models import ResourceLocationDataContract - from ._models import ResourceSku - from ._models import ResourceSkuCapacity - from ._models import ResourceSkuResult - from ._models import ResponseContract - from ._models import SamplingSettings - from ._models import SaveConfigurationParameter - from ._models import SchemaContract - from ._models import SubscriptionContract - from ._models import SubscriptionCreateParameters - from ._models import SubscriptionKeyParameterNamesContract - from ._models import SubscriptionKeysContract - from ._models import SubscriptionsDelegationSettingsProperties - from ._models import SubscriptionUpdateParameters - from ._models import TagContract - from ._models import TagCreateUpdateParameters - from ._models import TagDescriptionContract - from ._models import TagDescriptionCreateParameters - from ._models import TagResourceContract - from ._models import TagTagResourceContractProperties - from ._models import TenantConfigurationSyncStateContract - from ._models import TermsOfServiceProperties - from ._models import TokenBodyParameterContract - from ._models import UserContract - from ._models import UserCreateParameters - from ._models import UserEntityBaseParameters - from ._models import UserIdentityContract - from ._models import UserIdentityProperties - from ._models import UserTokenParameters - from ._models import UserTokenResult - from ._models import UserUpdateParameters - from ._models import VirtualNetworkConfiguration - from ._models import X509CertificateName -from ._paged_models import ApiContractPaged -from ._paged_models import ApiManagementServiceResourcePaged -from ._paged_models import ApiReleaseContractPaged -from ._paged_models import ApiRevisionContractPaged -from ._paged_models import ApiVersionSetContractPaged -from ._paged_models import AuthorizationServerContractPaged -from ._paged_models import BackendContractPaged -from ._paged_models import CacheContractPaged -from ._paged_models import CertificateContractPaged -from ._paged_models import DiagnosticContractPaged -from ._paged_models import EmailTemplateContractPaged -from ._paged_models import GatewayContractPaged -from ._paged_models import GatewayHostnameConfigurationContractPaged -from ._paged_models import GroupContractPaged -from ._paged_models import IdentityProviderContractPaged -from ._paged_models import IssueAttachmentContractPaged -from ._paged_models import IssueCommentContractPaged -from ._paged_models import IssueContractPaged -from ._paged_models import LoggerContractPaged -from ._paged_models import NamedValueContractPaged -from ._paged_models import NotificationContractPaged -from ._paged_models import OpenidConnectProviderContractPaged -from ._paged_models import OperationContractPaged -from ._paged_models import OperationPaged -from ._paged_models import ProductContractPaged -from ._paged_models import RegionContractPaged -from ._paged_models import ReportRecordContractPaged -from ._paged_models import RequestReportRecordContractPaged -from ._paged_models import ResourceSkuResultPaged -from ._paged_models import SchemaContractPaged -from ._paged_models import SubscriptionContractPaged -from ._paged_models import TagContractPaged -from ._paged_models import TagDescriptionContractPaged -from ._paged_models import TagResourceContractPaged -from ._paged_models import UserContractPaged -from ._paged_models import UserIdentityContractPaged + from ._models import AccessInformationContract # type: ignore + from ._models import AccessInformationUpdateParameters # type: ignore + from ._models import AdditionalLocation # type: ignore + from ._models import ApiCollection # type: ignore + from ._models import ApiContract # type: ignore + from ._models import ApiContractProperties # type: ignore + from ._models import ApiContractUpdateProperties # type: ignore + from ._models import ApiCreateOrUpdateParameter # type: ignore + from ._models import ApiCreateOrUpdateProperties # type: ignore + from ._models import ApiCreateOrUpdatePropertiesWsdlSelector # type: ignore + from ._models import ApiEntityBaseContract # type: ignore + from ._models import ApiExportResult # type: ignore + from ._models import ApiExportResultValue # type: ignore + from ._models import ApiManagementServiceApplyNetworkConfigurationParameters # type: ignore + from ._models import ApiManagementServiceBackupRestoreParameters # type: ignore + from ._models import ApiManagementServiceBaseProperties # type: ignore + from ._models import ApiManagementServiceCheckNameAvailabilityParameters # type: ignore + from ._models import ApiManagementServiceGetSsoTokenResult # type: ignore + from ._models import ApiManagementServiceIdentity # type: ignore + from ._models import ApiManagementServiceListResult # type: ignore + from ._models import ApiManagementServiceNameAvailabilityResult # type: ignore + from ._models import ApiManagementServiceProperties # type: ignore + from ._models import ApiManagementServiceResource # type: ignore + from ._models import ApiManagementServiceSkuProperties # type: ignore + from ._models import ApiManagementServiceUpdateParameters # type: ignore + from ._models import ApiManagementServiceUpdateProperties # type: ignore + from ._models import ApiReleaseCollection # type: ignore + from ._models import ApiReleaseContract # type: ignore + from ._models import ApiRevisionCollection # type: ignore + from ._models import ApiRevisionContract # type: ignore + from ._models import ApiRevisionInfoContract # type: ignore + from ._models import ApiTagResourceContractProperties # type: ignore + from ._models import ApiUpdateContract # type: ignore + from ._models import ApiVersionConstraint # type: ignore + from ._models import ApiVersionSetCollection # type: ignore + from ._models import ApiVersionSetContract # type: ignore + from ._models import ApiVersionSetContractDetails # type: ignore + from ._models import ApiVersionSetContractProperties # type: ignore + from ._models import ApiVersionSetEntityBase # type: ignore + from ._models import ApiVersionSetUpdateParameters # type: ignore + from ._models import ApiVersionSetUpdateParametersProperties # type: ignore + from ._models import ApimResource # type: ignore + from ._models import AssociationContract # type: ignore + from ._models import AuthenticationSettingsContract # type: ignore + from ._models import AuthorizationServerCollection # type: ignore + from ._models import AuthorizationServerContract # type: ignore + from ._models import AuthorizationServerContractBaseProperties # type: ignore + from ._models import AuthorizationServerContractProperties # type: ignore + from ._models import AuthorizationServerSecretsContract # type: ignore + from ._models import AuthorizationServerUpdateContract # type: ignore + from ._models import AuthorizationServerUpdateContractProperties # type: ignore + from ._models import BackendAuthorizationHeaderCredentials # type: ignore + from ._models import BackendBaseParameters # type: ignore + from ._models import BackendCollection # type: ignore + from ._models import BackendContract # type: ignore + from ._models import BackendContractProperties # type: ignore + from ._models import BackendCredentialsContract # type: ignore + from ._models import BackendProperties # type: ignore + from ._models import BackendProxyContract # type: ignore + from ._models import BackendReconnectContract # type: ignore + from ._models import BackendServiceFabricClusterProperties # type: ignore + from ._models import BackendTlsProperties # type: ignore + from ._models import BackendUpdateParameterProperties # type: ignore + from ._models import BackendUpdateParameters # type: ignore + from ._models import BodyDiagnosticSettings # type: ignore + from ._models import CacheCollection # type: ignore + from ._models import CacheContract # type: ignore + from ._models import CacheUpdateParameters # type: ignore + from ._models import CertificateCollection # type: ignore + from ._models import CertificateConfiguration # type: ignore + from ._models import CertificateContract # type: ignore + from ._models import CertificateCreateOrUpdateParameters # type: ignore + from ._models import CertificateInformation # type: ignore + from ._models import ClientSecretContract # type: ignore + from ._models import ConnectivityStatusContract # type: ignore + from ._models import ContentItemCollection # type: ignore + from ._models import ContentItemContract # type: ignore + from ._models import ContentTypeCollection # type: ignore + from ._models import ContentTypeContract # type: ignore + from ._models import DataMasking # type: ignore + from ._models import DataMaskingEntity # type: ignore + from ._models import DeletedServiceContract # type: ignore + from ._models import DeletedServicesCollection # type: ignore + from ._models import DeployConfigurationParameters # type: ignore + from ._models import DiagnosticCollection # type: ignore + from ._models import DiagnosticContract # type: ignore + from ._models import EmailTemplateCollection # type: ignore + from ._models import EmailTemplateContract # type: ignore + from ._models import EmailTemplateParametersContractProperties # type: ignore + from ._models import EmailTemplateUpdateParameters # type: ignore + from ._models import ErrorFieldContract # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import ErrorResponseBody # type: ignore + from ._models import GatewayCollection # type: ignore + from ._models import GatewayContract # type: ignore + from ._models import GatewayHostnameConfigurationCollection # type: ignore + from ._models import GatewayHostnameConfigurationContract # type: ignore + from ._models import GatewayKeyRegenerationRequestContract # type: ignore + from ._models import GatewayKeysContract # type: ignore + from ._models import GatewayTokenContract # type: ignore + from ._models import GatewayTokenRequestContract # type: ignore + from ._models import GenerateSsoUrlResult # type: ignore + from ._models import GroupCollection # type: ignore + from ._models import GroupContract # type: ignore + from ._models import GroupContractProperties # type: ignore + from ._models import GroupCreateParameters # type: ignore + from ._models import GroupUpdateParameters # type: ignore + from ._models import HostnameConfiguration # type: ignore + from ._models import HttpMessageDiagnostic # type: ignore + from ._models import IdentityProviderBaseParameters # type: ignore + from ._models import IdentityProviderContract # type: ignore + from ._models import IdentityProviderContractProperties # type: ignore + from ._models import IdentityProviderCreateContract # type: ignore + from ._models import IdentityProviderCreateContractProperties # type: ignore + from ._models import IdentityProviderList # type: ignore + from ._models import IdentityProviderUpdateParameters # type: ignore + from ._models import IdentityProviderUpdateProperties # type: ignore + from ._models import IssueAttachmentCollection # type: ignore + from ._models import IssueAttachmentContract # type: ignore + from ._models import IssueCollection # type: ignore + from ._models import IssueCommentCollection # type: ignore + from ._models import IssueCommentContract # type: ignore + from ._models import IssueContract # type: ignore + from ._models import IssueContractBaseProperties # type: ignore + from ._models import IssueContractProperties # type: ignore + from ._models import IssueUpdateContract # type: ignore + from ._models import IssueUpdateContractProperties # type: ignore + from ._models import KeyVaultContractCreateProperties # type: ignore + from ._models import KeyVaultContractProperties # type: ignore + from ._models import KeyVaultLastAccessStatusContractProperties # type: ignore + from ._models import LoggerCollection # type: ignore + from ._models import LoggerContract # type: ignore + from ._models import LoggerUpdateContract # type: ignore + from ._models import NamedValueCollection # type: ignore + from ._models import NamedValueContract # type: ignore + from ._models import NamedValueContractProperties # type: ignore + from ._models import NamedValueCreateContract # type: ignore + from ._models import NamedValueCreateContractProperties # type: ignore + from ._models import NamedValueEntityBaseParameters # type: ignore + from ._models import NamedValueSecretContract # type: ignore + from ._models import NamedValueUpdateParameterProperties # type: ignore + from ._models import NamedValueUpdateParameters # type: ignore + from ._models import NetworkStatusContract # type: ignore + from ._models import NetworkStatusContractByLocation # type: ignore + from ._models import NotificationCollection # type: ignore + from ._models import NotificationContract # type: ignore + from ._models import OAuth2AuthenticationSettingsContract # type: ignore + from ._models import OpenIdAuthenticationSettingsContract # type: ignore + from ._models import OpenIdConnectProviderCollection # type: ignore + from ._models import OpenidConnectProviderContract # type: ignore + from ._models import OpenidConnectProviderUpdateContract # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationCollection # type: ignore + from ._models import OperationContract # type: ignore + from ._models import OperationContractProperties # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationEntityBaseContract # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import OperationResultContract # type: ignore + from ._models import OperationResultLogItemContract # type: ignore + from ._models import OperationTagResourceContractProperties # type: ignore + from ._models import OperationUpdateContract # type: ignore + from ._models import OperationUpdateContractProperties # type: ignore + from ._models import ParameterContract # type: ignore + from ._models import PipelineDiagnosticSettings # type: ignore + from ._models import PolicyCollection # type: ignore + from ._models import PolicyContract # type: ignore + from ._models import PolicyDescriptionCollection # type: ignore + from ._models import PolicyDescriptionContract # type: ignore + from ._models import PortalDelegationSettings # type: ignore + from ._models import PortalSettingValidationKeyContract # type: ignore + from ._models import PortalSigninSettings # type: ignore + from ._models import PortalSignupSettings # type: ignore + from ._models import ProductCollection # type: ignore + from ._models import ProductContract # type: ignore + from ._models import ProductContractProperties # type: ignore + from ._models import ProductEntityBaseParameters # type: ignore + from ._models import ProductTagResourceContractProperties # type: ignore + from ._models import ProductUpdateParameters # type: ignore + from ._models import ProductUpdateProperties # type: ignore + from ._models import QuotaCounterCollection # type: ignore + from ._models import QuotaCounterContract # type: ignore + from ._models import QuotaCounterValueContract # type: ignore + from ._models import QuotaCounterValueContractProperties # type: ignore + from ._models import QuotaCounterValueUpdateContract # type: ignore + from ._models import RecipientEmailCollection # type: ignore + from ._models import RecipientEmailContract # type: ignore + from ._models import RecipientUserCollection # type: ignore + from ._models import RecipientUserContract # type: ignore + from ._models import RecipientsContractProperties # type: ignore + from ._models import RegionContract # type: ignore + from ._models import RegionListResult # type: ignore + from ._models import RegistrationDelegationSettingsProperties # type: ignore + from ._models import ReportCollection # type: ignore + from ._models import ReportRecordContract # type: ignore + from ._models import RepresentationContract # type: ignore + from ._models import RequestContract # type: ignore + from ._models import RequestReportCollection # type: ignore + from ._models import RequestReportRecordContract # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceLocationDataContract # type: ignore + from ._models import ResourceSku # type: ignore + from ._models import ResourceSkuCapacity # type: ignore + from ._models import ResourceSkuResult # type: ignore + from ._models import ResourceSkuResults # type: ignore + from ._models import ResponseContract # type: ignore + from ._models import SamplingSettings # type: ignore + from ._models import SaveConfigurationParameter # type: ignore + from ._models import SchemaCollection # type: ignore + from ._models import SchemaContract # type: ignore + from ._models import SubscriptionCollection # type: ignore + from ._models import SubscriptionContract # type: ignore + from ._models import SubscriptionCreateParameters # type: ignore + from ._models import SubscriptionKeyParameterNamesContract # type: ignore + from ._models import SubscriptionKeysContract # type: ignore + from ._models import SubscriptionUpdateParameters # type: ignore + from ._models import SubscriptionsDelegationSettingsProperties # type: ignore + from ._models import TagCollection # type: ignore + from ._models import TagContract # type: ignore + from ._models import TagCreateUpdateParameters # type: ignore + from ._models import TagDescriptionBaseProperties # type: ignore + from ._models import TagDescriptionCollection # type: ignore + from ._models import TagDescriptionContract # type: ignore + from ._models import TagDescriptionContractProperties # type: ignore + from ._models import TagDescriptionCreateParameters # type: ignore + from ._models import TagResourceCollection # type: ignore + from ._models import TagResourceContract # type: ignore + from ._models import TagResourceContractProperties # type: ignore + from ._models import TenantConfigurationSyncStateContract # type: ignore + from ._models import TermsOfServiceProperties # type: ignore + from ._models import TokenBodyParameterContract # type: ignore + from ._models import UserCollection # type: ignore + from ._models import UserContract # type: ignore + from ._models import UserContractProperties # type: ignore + from ._models import UserCreateParameterProperties # type: ignore + from ._models import UserCreateParameters # type: ignore + from ._models import UserEntityBaseParameters # type: ignore + from ._models import UserIdentityCollection # type: ignore + from ._models import UserIdentityContract # type: ignore + from ._models import UserIdentityProperties # type: ignore + from ._models import UserTokenParameters # type: ignore + from ._models import UserTokenResult # type: ignore + from ._models import UserUpdateParameters # type: ignore + from ._models import UserUpdateParametersProperties # type: ignore + from ._models import VirtualNetworkConfiguration # type: ignore + from ._models import X509CertificateName # type: ignore + from ._api_management_client_enums import ( - ExportResultFormat, - ProductState, - BearerTokenSendingMethods, - Protocol, - ContentFormat, - SoapApiType, - ApiType, - State, - SamplingType, + AccessIdName, AlwaysLog, - HttpCorrelationProtocol, - Verbosity, - PolicyContentFormat, - VersioningScheme, - GrantType, - AuthorizationMethod, - ClientAuthenticationMethod, - BearerTokenSendingMethod, - BackendProtocol, - SkuType, - ResourceSkuCapacityScaleType, - HostnameType, - VirtualNetworkType, + ApiType, + ApiVersionSetContractDetailsVersioningScheme, ApimIdentityType, - NameAvailabilityReason, - ProvisioningState, - KeyType, AppType, + AsyncOperationStatus, + AuthorizationMethod, + BackendProtocol, + BearerTokenSendingMethod, + BearerTokenSendingMethods, + CertificateConfigurationStoreName, + ClientAuthenticationMethod, + ConfigurationIdName, Confirmation, - UserState, + ConnectivityStatusType, + ContentFormat, + DataMaskingMode, + ExportApi, + ExportFormat, + ExportResultFormat, + GrantType, GroupType, + HostnameType, + HttpCorrelationProtocol, IdentityProviderType, + KeyType, LoggerType, - ConnectivityStatusType, - SubscriptionState, - AsyncOperationStatus, + NameAvailabilityReason, NotificationName, + OperationNameFormat, + PolicyContentFormat, PolicyExportFormat, - TemplateName, + PolicyIdName, PolicyScopeContract, - ExportFormat, + ProductState, + Protocol, + ResourceSkuCapacityScaleType, + SamplingType, + SkuType, + SoapApiType, + State, + SubscriptionState, + TemplateName, + UserState, + Verbosity, + VersioningScheme, + VirtualNetworkType, ) __all__ = [ 'AccessInformationContract', 'AccessInformationUpdateParameters', 'AdditionalLocation', + 'ApiCollection', 'ApiContract', 'ApiContractProperties', + 'ApiContractUpdateProperties', 'ApiCreateOrUpdateParameter', + 'ApiCreateOrUpdateProperties', 'ApiCreateOrUpdatePropertiesWsdlSelector', 'ApiEntityBaseContract', 'ApiExportResult', @@ -448,60 +572,90 @@ 'ApiManagementServiceCheckNameAvailabilityParameters', 'ApiManagementServiceGetSsoTokenResult', 'ApiManagementServiceIdentity', + 'ApiManagementServiceListResult', 'ApiManagementServiceNameAvailabilityResult', + 'ApiManagementServiceProperties', 'ApiManagementServiceResource', 'ApiManagementServiceSkuProperties', 'ApiManagementServiceUpdateParameters', - 'ApimResource', + 'ApiManagementServiceUpdateProperties', + 'ApiReleaseCollection', 'ApiReleaseContract', + 'ApiRevisionCollection', 'ApiRevisionContract', 'ApiRevisionInfoContract', 'ApiTagResourceContractProperties', 'ApiUpdateContract', 'ApiVersionConstraint', + 'ApiVersionSetCollection', 'ApiVersionSetContract', 'ApiVersionSetContractDetails', + 'ApiVersionSetContractProperties', 'ApiVersionSetEntityBase', 'ApiVersionSetUpdateParameters', + 'ApiVersionSetUpdateParametersProperties', + 'ApimResource', 'AssociationContract', 'AuthenticationSettingsContract', + 'AuthorizationServerCollection', 'AuthorizationServerContract', 'AuthorizationServerContractBaseProperties', + 'AuthorizationServerContractProperties', + 'AuthorizationServerSecretsContract', 'AuthorizationServerUpdateContract', + 'AuthorizationServerUpdateContractProperties', 'BackendAuthorizationHeaderCredentials', 'BackendBaseParameters', + 'BackendCollection', 'BackendContract', + 'BackendContractProperties', 'BackendCredentialsContract', 'BackendProperties', 'BackendProxyContract', 'BackendReconnectContract', 'BackendServiceFabricClusterProperties', 'BackendTlsProperties', + 'BackendUpdateParameterProperties', 'BackendUpdateParameters', 'BodyDiagnosticSettings', + 'CacheCollection', 'CacheContract', 'CacheUpdateParameters', + 'CertificateCollection', 'CertificateConfiguration', 'CertificateContract', 'CertificateCreateOrUpdateParameters', 'CertificateInformation', 'ClientSecretContract', 'ConnectivityStatusContract', + 'ContentItemCollection', + 'ContentItemContract', + 'ContentTypeCollection', + 'ContentTypeContract', + 'DataMasking', + 'DataMaskingEntity', + 'DeletedServiceContract', + 'DeletedServicesCollection', 'DeployConfigurationParameters', + 'DiagnosticCollection', 'DiagnosticContract', + 'EmailTemplateCollection', 'EmailTemplateContract', 'EmailTemplateParametersContractProperties', 'EmailTemplateUpdateParameters', 'ErrorFieldContract', - 'ErrorResponse', 'ErrorResponseException', + 'ErrorResponse', 'ErrorResponseBody', + 'GatewayCollection', 'GatewayContract', + 'GatewayHostnameConfigurationCollection', 'GatewayHostnameConfigurationContract', 'GatewayKeyRegenerationRequestContract', 'GatewayKeysContract', 'GatewayTokenContract', 'GatewayTokenRequestContract', 'GenerateSsoUrlResult', + 'GroupCollection', 'GroupContract', 'GroupContractProperties', 'GroupCreateParameters', @@ -510,34 +664,58 @@ 'HttpMessageDiagnostic', 'IdentityProviderBaseParameters', 'IdentityProviderContract', + 'IdentityProviderContractProperties', 'IdentityProviderCreateContract', + 'IdentityProviderCreateContractProperties', + 'IdentityProviderList', 'IdentityProviderUpdateParameters', + 'IdentityProviderUpdateProperties', + 'IssueAttachmentCollection', 'IssueAttachmentContract', + 'IssueCollection', + 'IssueCommentCollection', 'IssueCommentContract', 'IssueContract', 'IssueContractBaseProperties', + 'IssueContractProperties', 'IssueUpdateContract', + 'IssueUpdateContractProperties', + 'KeyVaultContractCreateProperties', + 'KeyVaultContractProperties', + 'KeyVaultLastAccessStatusContractProperties', + 'LoggerCollection', 'LoggerContract', 'LoggerUpdateContract', + 'NamedValueCollection', 'NamedValueContract', + 'NamedValueContractProperties', 'NamedValueCreateContract', + 'NamedValueCreateContractProperties', 'NamedValueEntityBaseParameters', + 'NamedValueSecretContract', + 'NamedValueUpdateParameterProperties', 'NamedValueUpdateParameters', 'NetworkStatusContract', 'NetworkStatusContractByLocation', + 'NotificationCollection', 'NotificationContract', 'OAuth2AuthenticationSettingsContract', 'OpenIdAuthenticationSettingsContract', + 'OpenIdConnectProviderCollection', 'OpenidConnectProviderContract', 'OpenidConnectProviderUpdateContract', 'Operation', + 'OperationCollection', 'OperationContract', + 'OperationContractProperties', 'OperationDisplay', 'OperationEntityBaseContract', + 'OperationListResult', 'OperationResultContract', 'OperationResultLogItemContract', 'OperationTagResourceContractProperties', 'OperationUpdateContract', + 'OperationUpdateContractProperties', 'ParameterContract', 'PipelineDiagnosticSettings', 'PolicyCollection', @@ -548,135 +726,125 @@ 'PortalSettingValidationKeyContract', 'PortalSigninSettings', 'PortalSignupSettings', + 'ProductCollection', 'ProductContract', + 'ProductContractProperties', 'ProductEntityBaseParameters', 'ProductTagResourceContractProperties', 'ProductUpdateParameters', - 'PropertyValueContract', + 'ProductUpdateProperties', 'QuotaCounterCollection', 'QuotaCounterContract', 'QuotaCounterValueContract', 'QuotaCounterValueContractProperties', + 'QuotaCounterValueUpdateContract', 'RecipientEmailCollection', 'RecipientEmailContract', - 'RecipientsContractProperties', 'RecipientUserCollection', 'RecipientUserContract', + 'RecipientsContractProperties', 'RegionContract', + 'RegionListResult', 'RegistrationDelegationSettingsProperties', + 'ReportCollection', 'ReportRecordContract', 'RepresentationContract', 'RequestContract', + 'RequestReportCollection', 'RequestReportRecordContract', 'Resource', 'ResourceLocationDataContract', 'ResourceSku', 'ResourceSkuCapacity', 'ResourceSkuResult', + 'ResourceSkuResults', 'ResponseContract', 'SamplingSettings', 'SaveConfigurationParameter', + 'SchemaCollection', 'SchemaContract', + 'SubscriptionCollection', 'SubscriptionContract', 'SubscriptionCreateParameters', 'SubscriptionKeyParameterNamesContract', 'SubscriptionKeysContract', - 'SubscriptionsDelegationSettingsProperties', 'SubscriptionUpdateParameters', + 'SubscriptionsDelegationSettingsProperties', + 'TagCollection', 'TagContract', 'TagCreateUpdateParameters', + 'TagDescriptionBaseProperties', + 'TagDescriptionCollection', 'TagDescriptionContract', + 'TagDescriptionContractProperties', 'TagDescriptionCreateParameters', + 'TagResourceCollection', 'TagResourceContract', - 'TagTagResourceContractProperties', + 'TagResourceContractProperties', 'TenantConfigurationSyncStateContract', 'TermsOfServiceProperties', 'TokenBodyParameterContract', + 'UserCollection', 'UserContract', + 'UserContractProperties', + 'UserCreateParameterProperties', 'UserCreateParameters', 'UserEntityBaseParameters', + 'UserIdentityCollection', 'UserIdentityContract', 'UserIdentityProperties', 'UserTokenParameters', 'UserTokenResult', 'UserUpdateParameters', + 'UserUpdateParametersProperties', 'VirtualNetworkConfiguration', 'X509CertificateName', - 'ApiContractPaged', - 'TagResourceContractPaged', - 'ApiRevisionContractPaged', - 'ApiReleaseContractPaged', - 'OperationContractPaged', - 'TagContractPaged', - 'ProductContractPaged', - 'SchemaContractPaged', - 'DiagnosticContractPaged', - 'IssueContractPaged', - 'IssueCommentContractPaged', - 'IssueAttachmentContractPaged', - 'TagDescriptionContractPaged', - 'ApiVersionSetContractPaged', - 'AuthorizationServerContractPaged', - 'BackendContractPaged', - 'CacheContractPaged', - 'CertificateContractPaged', - 'OperationPaged', - 'ResourceSkuResultPaged', - 'ApiManagementServiceResourcePaged', - 'EmailTemplateContractPaged', - 'GatewayContractPaged', - 'GatewayHostnameConfigurationContractPaged', - 'GroupContractPaged', - 'UserContractPaged', - 'IdentityProviderContractPaged', - 'LoggerContractPaged', - 'NamedValueContractPaged', - 'NotificationContractPaged', - 'OpenidConnectProviderContractPaged', - 'SubscriptionContractPaged', - 'RegionContractPaged', - 'ReportRecordContractPaged', - 'RequestReportRecordContractPaged', - 'UserIdentityContractPaged', - 'ExportResultFormat', - 'ProductState', - 'BearerTokenSendingMethods', - 'Protocol', - 'ContentFormat', - 'SoapApiType', - 'ApiType', - 'State', - 'SamplingType', + 'AccessIdName', 'AlwaysLog', - 'HttpCorrelationProtocol', - 'Verbosity', - 'PolicyContentFormat', - 'VersioningScheme', - 'GrantType', - 'AuthorizationMethod', - 'ClientAuthenticationMethod', - 'BearerTokenSendingMethod', - 'BackendProtocol', - 'SkuType', - 'ResourceSkuCapacityScaleType', - 'HostnameType', - 'VirtualNetworkType', + 'ApiType', + 'ApiVersionSetContractDetailsVersioningScheme', 'ApimIdentityType', - 'NameAvailabilityReason', - 'ProvisioningState', - 'KeyType', 'AppType', + 'AsyncOperationStatus', + 'AuthorizationMethod', + 'BackendProtocol', + 'BearerTokenSendingMethod', + 'BearerTokenSendingMethods', + 'CertificateConfigurationStoreName', + 'ClientAuthenticationMethod', + 'ConfigurationIdName', 'Confirmation', - 'UserState', + 'ConnectivityStatusType', + 'ContentFormat', + 'DataMaskingMode', + 'ExportApi', + 'ExportFormat', + 'ExportResultFormat', + 'GrantType', 'GroupType', + 'HostnameType', + 'HttpCorrelationProtocol', 'IdentityProviderType', + 'KeyType', 'LoggerType', - 'ConnectivityStatusType', - 'SubscriptionState', - 'AsyncOperationStatus', + 'NameAvailabilityReason', 'NotificationName', + 'OperationNameFormat', + 'PolicyContentFormat', 'PolicyExportFormat', - 'TemplateName', + 'PolicyIdName', 'PolicyScopeContract', - 'ExportFormat', + 'ProductState', + 'Protocol', + 'ResourceSkuCapacityScaleType', + 'SamplingType', + 'SkuType', + 'SoapApiType', + 'State', + 'SubscriptionState', + 'TemplateName', + 'UserState', + 'Verbosity', + 'VersioningScheme', + 'VirtualNetworkType', ] 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 6c2944f5bc97..0147b3a2cfb2 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 @@ -1,328 +1,424 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum +from enum import Enum, EnumMeta +from six import with_metaclass +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) -class ExportResultFormat(str, Enum): + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) - swagger = "swagger-link-json" #: The Api Definition is exported in OpenApi Specification 2.0 format to the Storage Blob. - wsdl = "wsdl-link+xml" #: The Api Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs of Type `soap` - wadl = "wadl-link-json" #: Export the Api Definition in WADL Schema to Storage Blob. - open_api = "openapi-link" #: Export the Api Definition in OpenApi Specification 3.0 to Storage Blob. +class AccessIdName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class ProductState(str, Enum): + ACCESS = "access" - not_published = "notPublished" - published = "published" +class AlwaysLog(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies for what type of messages sampling settings should not apply. + """ + ALL_ERRORS = "allErrors" #: Always log all erroneous request regardless of sampling settings. -class BearerTokenSendingMethods(str, Enum): +class ApimIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes + both an implicitly created identity and a set of user assigned identities. The type 'None' will + remove any identities from the service. + """ - authorization_header = "authorizationHeader" #: Access token will be transmitted in the Authorization header using Bearer schema - query = "query" #: Access token will be transmitted as query parameters. + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + NONE = "None" +class ApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of API. + """ -class Protocol(str, Enum): + HTTP = "http" + SOAP = "soap" - http = "http" - https = "https" +class ApiVersionSetContractDetailsVersioningScheme(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """An value that determines where the API Version identifer will be located in a HTTP request. + """ + SEGMENT = "Segment" + QUERY = "Query" + HEADER = "Header" -class ContentFormat(str, Enum): +class AppType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - wadl_xml = "wadl-xml" #: The contents are inline and Content type is a WADL document. - wadl_link_json = "wadl-link-json" #: The WADL document is hosted on a publicly accessible internet address. - swagger_json = "swagger-json" #: The contents are inline and Content Type is a OpenApi 2.0 Document. - swagger_link_json = "swagger-link-json" #: The Open Api 2.0 document is hosted on a publicly accessible internet address. - wsdl = "wsdl" #: The contents are inline and the document is a WSDL/Soap document. - wsdl_link = "wsdl-link" #: The WSDL document is hosted on a publicly accessible internet address. - openapi = "openapi" #: The contents are inline and Content Type is a OpenApi 3.0 Document in YAML format. - openapijson = "openapi+json" #: The contents are inline and Content Type is a OpenApi 3.0 Document in JSON format. - openapi_link = "openapi-link" #: The Open Api 3.0 document is hosted on a publicly accessible internet address. - openapijson_link = "openapi+json-link" #: The Open Api 3.0 Json document is hosted on a publicly accessible internet address. + PORTAL = "portal" #: User create request was sent by legacy developer portal. + DEVELOPER_PORTAL = "developerPortal" #: User create request was sent by new developer portal. +class AsyncOperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of an async operation. + """ -class SoapApiType(str, Enum): + STARTED = "Started" + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" - soap_to_rest = "http" #: Imports a SOAP API having a RESTful front end. - soap_pass_through = "soap" #: Imports the Soap API having a SOAP front end. +class AuthorizationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + HEAD = "HEAD" + OPTIONS = "OPTIONS" + TRACE = "TRACE" + GET = "GET" + POST = "POST" + PUT = "PUT" + PATCH = "PATCH" + DELETE = "DELETE" -class ApiType(str, Enum): +class BackendProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Backend communication protocol. + """ - http = "http" - soap = "soap" + HTTP = "http" #: The Backend is a RESTful service. + SOAP = "soap" #: The Backend is a SOAP service. +class BearerTokenSendingMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class State(str, Enum): + AUTHORIZATION_HEADER = "authorizationHeader" + QUERY = "query" - proposed = "proposed" #: The issue is proposed. - open = "open" #: The issue is opened. - removed = "removed" #: The issue was removed. - resolved = "resolved" #: The issue is now resolved. - closed = "closed" #: The issue was closed. +class BearerTokenSendingMethods(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Form of an authorization grant, which the client uses to request the access token. + """ + AUTHORIZATION_HEADER = "authorizationHeader" #: Access token will be transmitted in the Authorization header using Bearer schema. + QUERY = "query" #: Access token will be transmitted as query parameters. -class SamplingType(str, Enum): +class CertificateConfigurationStoreName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only + Root and CertificateAuthority are valid locations. + """ - fixed = "fixed" #: Fixed-rate sampling. + CERTIFICATE_AUTHORITY = "CertificateAuthority" + ROOT = "Root" +class ClientAuthenticationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class AlwaysLog(str, Enum): + BASIC = "Basic" #: Basic Client Authentication method. + BODY = "Body" #: Body based Authentication method. - all_errors = "allErrors" #: Always log all erroneous request regardless of sampling settings. +class ConfigurationIdName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + CONFIGURATION = "configuration" -class HttpCorrelationProtocol(str, Enum): +class Confirmation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Determines the type of confirmation e-mail that will be sent to the newly created user. + """ - none = "None" #: Do not read and inject correlation headers. - legacy = "Legacy" #: Inject Request-Id and Request-Context headers with request correlation data. See https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md. - w3_c = "W3C" #: Inject Trace Context headers. See https://w3c.github.io/trace-context. + SIGNUP = "signup" #: Send an e-mail to the user confirming they have successfully signed up. + INVITE = "invite" #: Send an e-mail inviting the user to sign-up and complete registration. +class ConnectivityStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Resource Connectivity Status Type identifier. + """ -class Verbosity(str, Enum): + INITIALIZING = "initializing" + SUCCESS = "success" + FAILURE = "failure" - verbose = "verbose" #: All the traces emitted by trace policies will be sent to the logger attached to this diagnostic instance. - information = "information" #: Traces with 'severity' set to 'information' and 'error' will be sent to the logger attached to this diagnostic instance. - error = "error" #: Only traces with 'severity' set to 'error' will be sent to the logger attached to this diagnostic instance. +class ContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Format of the Content in which the API is getting imported. + """ + WADL_XML = "wadl-xml" #: The contents are inline and Content type is a WADL document. + WADL_LINK_JSON = "wadl-link-json" #: The WADL document is hosted on a publicly accessible internet address. + SWAGGER_JSON = "swagger-json" #: The contents are inline and Content Type is a OpenApi 2.0 Document. + SWAGGER_LINK_JSON = "swagger-link-json" #: The Open Api 2.0 document is hosted on a publicly accessible internet address. + WSDL = "wsdl" #: The contents are inline and the document is a WSDL/Soap document. + WSDL_LINK = "wsdl-link" #: The WSDL document is hosted on a publicly accessible internet address. + OPENAPI = "openapi" #: The contents are inline and Content Type is a OpenApi 3.0 Document in YAML format. + OPENAPI_JSON = "openapi+json" #: The contents are inline and Content Type is a OpenApi 3.0 Document in JSON format. + OPENAPI_LINK = "openapi-link" #: The Open Api 3.0 document is hosted on a publicly accessible internet address. + OPENAPI_JSON_LINK = "openapi+json-link" #: The Open Api 3.0 Json document is hosted on a publicly accessible internet address. -class PolicyContentFormat(str, Enum): +class DataMaskingMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Data masking mode. + """ - xml = "xml" #: The contents are inline and Content type is an XML document. - xml_link = "xml-link" #: The policy XML document is hosted on a http endpoint accessible from the API Management service. - rawxml = "rawxml" #: The contents are inline and Content type is a non XML encoded policy document. - rawxml_link = "rawxml-link" #: The policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service. + MASK = "Mask" #: Mask the value of an entity. + HIDE = "Hide" #: Hide the presence of an entity. +class ExportApi(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class VersioningScheme(str, Enum): + TRUE = "true" - segment = "Segment" #: The API Version is passed in a path segment. - query = "Query" #: The API Version is passed in a query parameter. - header = "Header" #: The API Version is passed in a HTTP header. +class ExportFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + SWAGGER = "swagger-link" #: Export the Api Definition in OpenApi Specification 2.0 format to the Storage Blob. + WSDL = "wsdl-link" #: Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for APIs of Type ``soap``. + WADL = "wadl-link" #: Export the Api Definition in WADL Schema to Storage Blob. + OPENAPI = "openapi-link" #: Export the Api Definition in OpenApi Specification 3.0 to Storage Blob. + OPENAPI_JSON = "openapi+json-link" #: Export the Api Definition in OpenApi Specification 3.0 as JSON document to Storage Blob. -class GrantType(str, Enum): +class ExportResultFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Format in which the Api Details are exported to the Storage Blob with Sas Key valid for 5 + minutes. + """ - authorization_code = "authorizationCode" #: Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. - implicit = "implicit" #: Implicit Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.2. - resource_owner_password = "resourceOwnerPassword" #: Resource Owner Password Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.3. - client_credentials = "clientCredentials" #: Client Credentials Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.4. + SWAGGER = "swagger-link-json" #: The Api Definition is exported in OpenApi Specification 2.0 format to the Storage Blob. + WSDL = "wsdl-link+xml" #: The Api Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs of Type ``soap``. + WADL = "wadl-link-json" #: Export the Api Definition in WADL Schema to Storage Blob. + OPEN_API = "openapi-link" #: Export the Api Definition in OpenApi Specification 3.0 to Storage Blob. +class GrantType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): -class AuthorizationMethod(str, Enum): + AUTHORIZATION_CODE = "authorizationCode" #: Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. + IMPLICIT = "implicit" #: Implicit Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.2. + RESOURCE_OWNER_PASSWORD = "resourceOwnerPassword" #: Resource Owner Password Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.3. + CLIENT_CREDENTIALS = "clientCredentials" #: Client Credentials Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.4. - head = "HEAD" - options = "OPTIONS" - trace = "TRACE" - get = "GET" - post = "POST" - put = "PUT" - patch = "PATCH" - delete = "DELETE" +class GroupType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Group type. + """ + CUSTOM = "custom" + SYSTEM = "system" + EXTERNAL = "external" -class ClientAuthenticationMethod(str, Enum): +class HostnameType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Hostname type. + """ - basic = "Basic" #: Basic Client Authentication method. - body = "Body" #: Body based Authentication method. + PROXY = "Proxy" + PORTAL = "Portal" + MANAGEMENT = "Management" + SCM = "Scm" + DEVELOPER_PORTAL = "DeveloperPortal" +class HttpCorrelationProtocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Sets correlation protocol to use for Application Insights diagnostics. + """ -class BearerTokenSendingMethod(str, Enum): + NONE = "None" #: Do not read and inject correlation headers. + LEGACY = "Legacy" #: Inject Request-Id and Request-Context headers with request correlation data. See https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md. + W3_C = "W3C" #: Inject Trace Context headers. See https://w3c.github.io/trace-context. - authorization_header = "authorizationHeader" - query = "query" +class IdentityProviderType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + FACEBOOK = "facebook" #: Facebook as Identity provider. + GOOGLE = "google" #: Google as Identity provider. + MICROSOFT = "microsoft" #: Microsoft Live as Identity provider. + TWITTER = "twitter" #: Twitter as Identity provider. + AAD = "aad" #: Azure Active Directory as Identity provider. + AAD_B2_C = "aadB2C" #: Azure Active Directory B2C as Identity provider. -class BackendProtocol(str, Enum): +class KeyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The Key to be used to generate token for user. + """ - http = "http" #: The Backend is a RESTful service. - soap = "soap" #: The Backend is a SOAP service. + PRIMARY = "primary" + SECONDARY = "secondary" +class LoggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Logger type. + """ + + AZURE_EVENT_HUB = "azureEventHub" #: Azure Event Hub as log destination. + APPLICATION_INSIGHTS = "applicationInsights" #: Azure Application Insights as log destination. + AZURE_MONITOR = "azureMonitor" #: Azure Monitor. + +class NameAvailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Invalid indicates the name provided does not match the resource provider’s naming requirements + (incorrect length, unsupported characters, etc.) AlreadyExists indicates that the name is + already in use and is therefore unavailable. + """ + + VALID = "Valid" + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" -class SkuType(str, Enum): +class NotificationName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - developer = "Developer" #: Developer SKU of Api Management. - standard = "Standard" #: Standard SKU of Api Management. - premium = "Premium" #: Premium SKU of Api Management. - basic = "Basic" #: Basic SKU of Api Management. - consumption = "Consumption" #: Consumption SKU of Api Management. - - -class ResourceSkuCapacityScaleType(str, Enum): - - automatic = "automatic" #: Supported scale type automatic. - manual = "manual" #: Supported scale type manual. - none = "none" #: Scaling not supported. - - -class HostnameType(str, Enum): - - proxy = "Proxy" - portal = "Portal" - management = "Management" - scm = "Scm" - developer_portal = "DeveloperPortal" - - -class VirtualNetworkType(str, Enum): - - none = "None" #: The service is not part of any Virtual Network. - external = "External" #: The service is part of Virtual Network and it is accessible from Internet. - internal = "Internal" #: The service is part of Virtual Network and it is only accessible from within the virtual network. - - -class ApimIdentityType(str, Enum): - - system_assigned = "SystemAssigned" - user_assigned = "UserAssigned" - system_assigned_user_assigned = "SystemAssigned, UserAssigned" - none = "None" - - -class NameAvailabilityReason(str, Enum): - - valid = "Valid" - invalid = "Invalid" - already_exists = "AlreadyExists" - - -class ProvisioningState(str, Enum): - - created = "created" - - -class KeyType(str, Enum): - - primary = "primary" - secondary = "secondary" - - -class AppType(str, Enum): - - developer_portal = "developerPortal" #: User create request was sent by new developer portal. - - -class Confirmation(str, Enum): - - signup = "signup" #: Send an e-mail to the user confirming they have successfully signed up. - invite = "invite" #: Send an e-mail inviting the user to sign-up and complete registration. - - -class UserState(str, Enum): - - active = "active" #: User state is active. - blocked = "blocked" #: User is blocked. Blocked users cannot authenticate at developer portal or call API. - pending = "pending" #: User account is pending. Requires identity confirmation before it can be made active. - deleted = "deleted" #: User account is closed. All identities and related entities are removed. - - -class GroupType(str, Enum): - - custom = "custom" - system = "system" - external = "external" - - -class IdentityProviderType(str, Enum): - - facebook = "facebook" #: Facebook as Identity provider. - google = "google" #: Google as Identity provider. - microsoft = "microsoft" #: Microsoft Live as Identity provider. - twitter = "twitter" #: Twitter as Identity provider. - aad = "aad" #: Azure Active Directory as Identity provider. - aad_b2_c = "aadB2C" #: Azure Active Directory B2C as Identity provider. - - -class LoggerType(str, Enum): - - azure_event_hub = "azureEventHub" #: Azure Event Hub as log destination. - application_insights = "applicationInsights" #: Azure Application Insights as log destination. - - -class ConnectivityStatusType(str, Enum): - - initializing = "initializing" - success = "success" - failure = "failure" - - -class SubscriptionState(str, Enum): - - suspended = "suspended" - active = "active" - expired = "expired" - submitted = "submitted" - rejected = "rejected" - cancelled = "cancelled" - - -class AsyncOperationStatus(str, Enum): - - started = "Started" - in_progress = "InProgress" - succeeded = "Succeeded" - failed = "Failed" - - -class NotificationName(str, Enum): - - request_publisher_notification_message = "RequestPublisherNotificationMessage" #: The following email recipients and users will receive email notifications about subscription requests for API products requiring approval. - purchase_publisher_notification_message = "PurchasePublisherNotificationMessage" #: The following email recipients and users will receive email notifications about new API product subscriptions. - new_application_notification_message = "NewApplicationNotificationMessage" #: The following email recipients and users will receive email notifications when new applications are submitted to the application gallery. - bcc = "BCC" #: The following recipients will receive blind carbon copies of all emails sent to developers. - new_issue_publisher_notification_message = "NewIssuePublisherNotificationMessage" #: The following email recipients and users will receive email notifications when a new issue or comment is submitted on the developer portal. - account_closed_publisher = "AccountClosedPublisher" #: The following email recipients and users will receive email notifications when developer closes his account. - quota_limit_approaching_publisher_notification_message = "QuotaLimitApproachingPublisherNotificationMessage" #: The following email recipients and users will receive email notifications when subscription usage gets close to usage quota. - - -class PolicyExportFormat(str, Enum): - - xml = "xml" #: The contents are inline and Content type is an XML document. - rawxml = "rawxml" #: The contents are inline and Content type is a non XML encoded policy document. - - -class TemplateName(str, Enum): - - application_approved_notification_message = "applicationApprovedNotificationMessage" - account_closed_developer = "accountClosedDeveloper" - quota_limit_approaching_developer_notification_message = "quotaLimitApproachingDeveloperNotificationMessage" - new_developer_notification_message = "newDeveloperNotificationMessage" - email_change_identity_default = "emailChangeIdentityDefault" - invite_user_notification_message = "inviteUserNotificationMessage" - new_comment_notification_message = "newCommentNotificationMessage" - confirm_sign_up_identity_default = "confirmSignUpIdentityDefault" - new_issue_notification_message = "newIssueNotificationMessage" - purchase_developer_notification_message = "purchaseDeveloperNotificationMessage" - password_reset_identity_default = "passwordResetIdentityDefault" - password_reset_by_admin_notification_message = "passwordResetByAdminNotificationMessage" - reject_developer_notification_message = "rejectDeveloperNotificationMessage" - request_developer_notification_message = "requestDeveloperNotificationMessage" - - -class PolicyScopeContract(str, Enum): - - tenant = "Tenant" - product = "Product" - api = "Api" - operation = "Operation" - all = "All" - - -class ExportFormat(str, Enum): - - swagger = "swagger-link" #: Export the Api Definition in OpenApi Specification 2.0 format to the Storage Blob. - wsdl = "wsdl-link" #: Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for APIs of Type `soap` - wadl = "wadl-link" #: Export the Api Definition in WADL Schema to Storage Blob. - openapi = "openapi-link" #: Export the Api Definition in OpenApi Specification 3.0 to Storage Blob. - openapi_json = "openapi+json-link" #: Export the Api Definition in OpenApi Specification 3.0 as JSON document to Storage Blob. + REQUEST_PUBLISHER_NOTIFICATION_MESSAGE = "RequestPublisherNotificationMessage" #: The following email recipients and users will receive email notifications about subscription requests for API products requiring approval. + PURCHASE_PUBLISHER_NOTIFICATION_MESSAGE = "PurchasePublisherNotificationMessage" #: The following email recipients and users will receive email notifications about new API product subscriptions. + NEW_APPLICATION_NOTIFICATION_MESSAGE = "NewApplicationNotificationMessage" #: The following email recipients and users will receive email notifications when new applications are submitted to the application gallery. + BCC = "BCC" #: The following recipients will receive blind carbon copies of all emails sent to developers. + NEW_ISSUE_PUBLISHER_NOTIFICATION_MESSAGE = "NewIssuePublisherNotificationMessage" #: The following email recipients and users will receive email notifications when a new issue or comment is submitted on the developer portal. + ACCOUNT_CLOSED_PUBLISHER = "AccountClosedPublisher" #: The following email recipients and users will receive email notifications when developer closes his account. + QUOTA_LIMIT_APPROACHING_PUBLISHER_NOTIFICATION_MESSAGE = "QuotaLimitApproachingPublisherNotificationMessage" #: The following email recipients and users will receive email notifications when subscription usage gets close to usage quota. + +class OperationNameFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The format of the Operation Name for Application Insights telemetries. Default is Name. + """ + + NAME = "Name" #: API_NAME;rev=API_REVISION - OPERATION_NAME. + URL = "Url" #: HTTP_VERB URL. + +class PolicyContentFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Format of the policyContent. + """ + + XML = "xml" #: The contents are inline and Content type is an XML document. + XML_LINK = "xml-link" #: The policy XML document is hosted on a http endpoint accessible from the API Management service. + RAWXML = "rawxml" #: The contents are inline and Content type is a non XML encoded policy document. + RAWXML_LINK = "rawxml-link" #: The policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service. + +class PolicyExportFormat(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + XML = "xml" #: The contents are inline and Content type is an XML document. + RAWXML = "rawxml" #: The contents are inline and Content type is a non XML encoded policy document. + +class PolicyIdName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + POLICY = "policy" + +class PolicyScopeContract(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + TENANT = "Tenant" + PRODUCT = "Product" + API = "Api" + OPERATION = "Operation" + ALL = "All" + +class ProductState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """whether product is published or not. Published products are discoverable by users of developer + portal. Non published products are visible only to administrators. Default state of Product is + notPublished. + """ + + NOT_PUBLISHED = "notPublished" + PUBLISHED = "published" + +class Protocol(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + HTTP = "http" + HTTPS = "https" + +class ResourceSkuCapacityScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The scale type applicable to the sku. + """ + + AUTOMATIC = "automatic" #: Supported scale type automatic. + MANUAL = "manual" #: Supported scale type manual. + NONE = "none" #: Scaling not supported. + +class SamplingType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Sampling type. + """ + + FIXED = "fixed" #: Fixed-rate sampling. + +class SkuType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Name of the Sku. + """ + + DEVELOPER = "Developer" #: Developer SKU of Api Management. + STANDARD = "Standard" #: Standard SKU of Api Management. + PREMIUM = "Premium" #: Premium SKU of Api Management. + BASIC = "Basic" #: Basic SKU of Api Management. + CONSUMPTION = "Consumption" #: Consumption SKU of Api Management. + ISOLATED = "Isolated" #: Isolated SKU of Api Management. + +class SoapApiType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of Api to create. + + + * ``http`` creates a SOAP to REST API + * ``soap`` creates a SOAP pass-through API . + """ + + SOAP_TO_REST = "http" #: Imports a SOAP API having a RESTful front end. + SOAP_PASS_THROUGH = "soap" #: Imports the Soap API having a SOAP front end. + +class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of the issue. + """ + + PROPOSED = "proposed" #: The issue is proposed. + OPEN = "open" #: The issue is opened. + REMOVED = "removed" #: The issue was removed. + RESOLVED = "resolved" #: The issue is now resolved. + CLOSED = "closed" #: The issue was closed. + +class SubscriptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Subscription state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + 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. + """ + + SUSPENDED = "suspended" + ACTIVE = "active" + EXPIRED = "expired" + SUBMITTED = "submitted" + REJECTED = "rejected" + CANCELLED = "cancelled" + +class TemplateName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + APPLICATION_APPROVED_NOTIFICATION_MESSAGE = "applicationApprovedNotificationMessage" + ACCOUNT_CLOSED_DEVELOPER = "accountClosedDeveloper" + QUOTA_LIMIT_APPROACHING_DEVELOPER_NOTIFICATION_MESSAGE = "quotaLimitApproachingDeveloperNotificationMessage" + NEW_DEVELOPER_NOTIFICATION_MESSAGE = "newDeveloperNotificationMessage" + EMAIL_CHANGE_IDENTITY_DEFAULT = "emailChangeIdentityDefault" + INVITE_USER_NOTIFICATION_MESSAGE = "inviteUserNotificationMessage" + NEW_COMMENT_NOTIFICATION_MESSAGE = "newCommentNotificationMessage" + CONFIRM_SIGN_UP_IDENTITY_DEFAULT = "confirmSignUpIdentityDefault" + NEW_ISSUE_NOTIFICATION_MESSAGE = "newIssueNotificationMessage" + PURCHASE_DEVELOPER_NOTIFICATION_MESSAGE = "purchaseDeveloperNotificationMessage" + PASSWORD_RESET_IDENTITY_DEFAULT = "passwordResetIdentityDefault" + PASSWORD_RESET_BY_ADMIN_NOTIFICATION_MESSAGE = "passwordResetByAdminNotificationMessage" + REJECT_DEVELOPER_NOTIFICATION_MESSAGE = "rejectDeveloperNotificationMessage" + REQUEST_DEVELOPER_NOTIFICATION_MESSAGE = "requestDeveloperNotificationMessage" + +class UserState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Account state. Specifies whether the user is active or not. Blocked users are unable to sign + into the developer portal or call any APIs of subscribed products. Default state is Active. + """ + + ACTIVE = "active" #: User state is active. + BLOCKED = "blocked" #: User is blocked. Blocked users cannot authenticate at developer portal or call API. + PENDING = "pending" #: User account is pending. Requires identity confirmation before it can be made active. + DELETED = "deleted" #: User account is closed. All identities and related entities are removed. + +class Verbosity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The verbosity level applied to traces emitted by trace policies. + """ + + VERBOSE = "verbose" #: All the traces emitted by trace policies will be sent to the logger attached to this diagnostic instance. + INFORMATION = "information" #: Traces with 'severity' set to 'information' and 'error' will be sent to the logger attached to this diagnostic instance. + ERROR = "error" #: Only traces with 'severity' set to 'error' will be sent to the logger attached to this diagnostic instance. + +class VersioningScheme(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """An value that determines where the API Version identifer will be located in a HTTP request. + """ + + SEGMENT = "Segment" #: The API Version is passed in a path segment. + QUERY = "Query" #: The API Version is passed in a query parameter. + HEADER = "Header" #: The API Version is passed in a HTTP header. + +class VirtualNetworkType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of VPN in which API Management service needs to be configured in. None (Default Value) + means the API Management service is not part of any Virtual Network, External means the API + Management deployment is set up inside a Virtual Network having an Internet Facing Endpoint, + and Internal means that API Management deployment is setup inside a Virtual Network having an + Intranet Facing Endpoint only. + """ + + NONE = "None" #: The service is not part of any Virtual Network. + EXTERNAL = "External" #: The service is part of Virtual Network and it is accessible from Internet. + INTERNAL = "Internal" #: The service is part of Virtual Network and it is only accessible from within the virtual network. diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py index 3e016257f412..9d221960a401 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models.py @@ -1,29 +1,25 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AccessInformationContract(Model): +class AccessInformationContract(msrest.serialization.Model): """Tenant access information contract of the API Management service. :param id: Identifier. :type id: str - :param primary_key: Primary access key. This property will not be filled - on 'GET' operations! Use '/listSecrets' POST request to get the value. + :param primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type primary_key: str - :param secondary_key: Secondary access key. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type secondary_key: str :param enabled: Determines whether direct access is enabled. :type enabled: bool @@ -36,7 +32,10 @@ class AccessInformationContract(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AccessInformationContract, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.primary_key = kwargs.get('primary_key', None) @@ -44,7 +43,7 @@ def __init__(self, **kwargs): self.enabled = kwargs.get('enabled', None) -class AccessInformationUpdateParameters(Model): +class AccessInformationUpdateParameters(msrest.serialization.Model): """Tenant access information update parameters. :param enabled: Determines whether direct access is enabled. @@ -55,44 +54,43 @@ class AccessInformationUpdateParameters(Model): 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AccessInformationUpdateParameters, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', None) -class AdditionalLocation(Model): +class AdditionalLocation(msrest.serialization.Model): """Description of an additional API Management resource location. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param location: Required. The location name of the additional region - among Azure Data center regions. + :param location: Required. The location name of the additional region among Azure Data center + regions. :type location: str :param sku: Required. SKU properties of the API Management service. - :type sku: - ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the - API Management service in the additional location. Available only for - Basic, Standard and Premium SKU. + :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :param zones: A list of availability zones denoting where the resource needs to come from. + :type zones: list[str] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in the additional location. Available only for Basic, Standard, Premium and Isolated + SKU. :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of - the API Management service which is deployed in an Internal Virtual - Network in a particular additional location. Available only for Basic, - Standard and Premium SKU. + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service which is deployed in an Internal Virtual Network in a particular additional location. + Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration for - the location. + :param virtual_network_configuration: Virtual network configuration for the location. :type virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar gateway_regional_url: Gateway URL of the API Management service in - the Region. + :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. :vartype gateway_regional_url: str - :param disable_gateway: Property only valid for an Api Management service - deployed in multiple locations. This can be used to disable the gateway in - this additional location. Default value: False . + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in this additional location. :type disable_gateway: bool """ @@ -107,6 +105,7 @@ class AdditionalLocation(Model): _attribute_map = { 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'ApiManagementServiceSkuProperties'}, + 'zones': {'key': 'zones', 'type': '[str]'}, 'public_ip_addresses': {'key': 'publicIPAddresses', 'type': '[str]'}, 'private_ip_addresses': {'key': 'privateIPAddresses', 'type': '[str]'}, 'virtual_network_configuration': {'key': 'virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, @@ -114,10 +113,14 @@ class AdditionalLocation(Model): 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AdditionalLocation, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.sku = kwargs.get('sku', None) + self.location = kwargs['location'] + self.sku = kwargs['sku'] + self.zones = kwargs.get('zones', None) self.public_ip_addresses = None self.private_ip_addresses = None self.virtual_network_configuration = kwargs.get('virtual_network_configuration', None) @@ -125,11 +128,40 @@ def __init__(self, **kwargs): self.disable_gateway = kwargs.get('disable_gateway', False) -class Resource(Model): +class ApiCollection(msrest.serialization.Model): + """Paged Api list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Resource(msrest.serialization.Model): """The Resource definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -151,7 +183,10 @@ class Resource(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -161,10 +196,7 @@ def __init__(self, **kwargs): class ApiContract(Resource): """Api details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -172,24 +204,19 @@ class ApiContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -199,30 +226,26 @@ class ApiContract(Resource): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -230,13 +253,13 @@ class ApiContract(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + 'path': {'max_length': 400, 'min_length': 0}, } _attribute_map = { @@ -259,11 +282,14 @@ class ApiContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, 'api_version_set': {'key': 'properties.apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authentication_settings = kwargs.get('authentication_settings', None) @@ -285,30 +311,24 @@ def __init__(self, **kwargs): self.api_version_set = kwargs.get('api_version_set', None) -class ApiEntityBaseContract(Model): +class ApiEntityBaseContract(msrest.serialization.Model): """API base contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -318,20 +338,19 @@ class ApiEntityBaseContract(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -349,7 +368,10 @@ class ApiEntityBaseContract(Model): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiEntityBaseContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authentication_settings = kwargs.get('authentication_settings', None) @@ -368,29 +390,23 @@ def __init__(self, **kwargs): class ApiContractProperties(ApiEntityBaseContract): """Api Entity Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -400,38 +416,34 @@ class ApiContractProperties(ApiEntityBaseContract): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + within the API Management service instance. It is appended to the API endpoint base URL + specified during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, 'path': {'required': True, 'max_length': 400, 'min_length': 0}, @@ -454,46 +466,126 @@ class ApiContractProperties(ApiEntityBaseContract): 'display_name': {'key': 'displayName', 'type': 'str'}, 'service_url': {'key': 'serviceUrl', 'type': 'str'}, 'path': {'key': 'path', 'type': 'str'}, - 'protocols': {'key': 'protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiContractProperties, self).__init__(**kwargs) self.source_api_id = kwargs.get('source_api_id', None) self.display_name = kwargs.get('display_name', None) self.service_url = kwargs.get('service_url', None) - self.path = kwargs.get('path', None) + self.path = kwargs['path'] self.protocols = kwargs.get('protocols', None) self.api_version_set = kwargs.get('api_version_set', None) -class ApiCreateOrUpdateParameter(Model): - """API Create or Update Parameters. +class ApiContractUpdateProperties(ApiEntityBaseContract): + """API update contract properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + :param description: Description of the API. May include HTML formatting tags. + :type description: str + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. + :type subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :param api_type: Type of API. Possible values include: "http", "soap". + :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. + :type api_revision: str + :param api_version: Indicates the Version identifier of the API if the API is versioned. + :type api_version: str + :param is_current: Indicates if API revision is current api revision. + :type is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :param api_revision_description: Description of the Api Revision. + :type api_revision_description: str + :param api_version_description: Description of the Api Version. + :type api_version_description: str + :param api_version_set_id: A resource identifier for the related ApiVersionSet. + :type api_version_set_id: str + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :type subscription_required: bool + :param display_name: API name. + :type display_name: str + :param service_url: Absolute URL of the backend service implementing this API. + :type service_url: str + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :type path: str + :param protocols: Describes on which protocols the operations in this API can be invoked. + :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + + _validation = { + 'api_revision': {'max_length': 100, 'min_length': 1}, + 'api_version': {'max_length': 100, 'min_length': 0}, + 'is_online': {'readonly': True}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'service_url': {'max_length': 2000, 'min_length': 1}, + 'path': {'max_length': 400, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authentication_settings': {'key': 'authenticationSettings', 'type': 'AuthenticationSettingsContract'}, + 'subscription_key_parameter_names': {'key': 'subscriptionKeyParameterNames', 'type': 'SubscriptionKeyParameterNamesContract'}, + 'api_type': {'key': 'type', 'type': 'str'}, + 'api_revision': {'key': 'apiRevision', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + 'is_current': {'key': 'isCurrent', 'type': 'bool'}, + 'is_online': {'key': 'isOnline', 'type': 'bool'}, + 'api_revision_description': {'key': 'apiRevisionDescription', 'type': 'str'}, + 'api_version_description': {'key': 'apiVersionDescription', 'type': 'str'}, + 'api_version_set_id': {'key': 'apiVersionSetId', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'service_url': {'key': 'serviceUrl', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiContractUpdateProperties, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.service_url = kwargs.get('service_url', None) + self.path = kwargs.get('path', None) + self.protocols = kwargs.get('protocols', None) + + +class ApiCreateOrUpdateParameter(msrest.serialization.Model): + """API Create or Update Parameters. + + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -503,57 +595,51 @@ class ApiCreateOrUpdateParameter(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :param value: Content value when Importing an API. :type value: str - :param format: Format of the Content in which the API is getting imported. - Possible values include: 'wadl-xml', 'wadl-link-json', 'swagger-json', - 'swagger-link-json', 'wsdl', 'wsdl-link', 'openapi', 'openapi+json', - 'openapi-link', 'openapi+json-link' + :param format: Format of the Content in which the API is getting imported. Possible values + include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl- + link", "openapi", "openapi+json", "openapi-link", "openapi+json-link". :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the - document. - :type wsdl_selector: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :param soap_api_type: Type of Api to create. - * `http` creates a SOAP to REST API - * `soap` creates a SOAP pass-through API. Possible values include: - 'SoapToRest', 'SoapPassThrough' + + + * ``http`` creates a SOAP to REST API + * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + 'path': {'max_length': 400, 'min_length': 0}, } _attribute_map = { @@ -573,7 +659,7 @@ class ApiCreateOrUpdateParameter(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, 'api_version_set': {'key': 'properties.apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, 'value': {'key': 'properties.value', 'type': 'str'}, 'format': {'key': 'properties.format', 'type': 'str'}, @@ -581,7 +667,10 @@ class ApiCreateOrUpdateParameter(Model): 'soap_api_type': {'key': 'properties.apiType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authentication_settings = kwargs.get('authentication_settings', None) @@ -607,12 +696,124 @@ def __init__(self, **kwargs): self.soap_api_type = kwargs.get('soap_api_type', None) -class ApiCreateOrUpdatePropertiesWsdlSelector(Model): +class ApiCreateOrUpdateProperties(ApiContractProperties): + """Api Create or Update Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of the API. May include HTML formatting tags. + :type description: str + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. + :type subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :param api_type: Type of API. Possible values include: "http", "soap". + :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. + :type api_revision: str + :param api_version: Indicates the Version identifier of the API if the API is versioned. + :type api_version: str + :param is_current: Indicates if API revision is current api revision. + :type is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :param api_revision_description: Description of the Api Revision. + :type api_revision_description: str + :param api_version_description: Description of the Api Version. + :type api_version_description: str + :param api_version_set_id: A resource identifier for the related ApiVersionSet. + :type api_version_set_id: str + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :type subscription_required: bool + :param source_api_id: API identifier of the source API. + :type source_api_id: str + :param display_name: API name. Must be 1 to 300 characters long. + :type display_name: str + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :type service_url: str + :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + within the API Management service instance. It is appended to the API endpoint base URL + specified during the service instance creation to form a public URL for this API. + :type path: str + :param protocols: Describes on which protocols the operations in this API can be invoked. + :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param value: Content value when Importing an API. + :type value: str + :param format: Format of the Content in which the API is getting imported. Possible values + include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl- + link", "openapi", "openapi+json", "openapi-link", "openapi+json-link". + :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat + :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :param soap_api_type: Type of Api to create. + + + * ``http`` creates a SOAP to REST API + * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". + :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + """ + + _validation = { + 'api_revision': {'max_length': 100, 'min_length': 1}, + 'api_version': {'max_length': 100, 'min_length': 0}, + 'is_online': {'readonly': True}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'service_url': {'max_length': 2000, 'min_length': 0}, + 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authentication_settings': {'key': 'authenticationSettings', 'type': 'AuthenticationSettingsContract'}, + 'subscription_key_parameter_names': {'key': 'subscriptionKeyParameterNames', 'type': 'SubscriptionKeyParameterNamesContract'}, + 'api_type': {'key': 'type', 'type': 'str'}, + 'api_revision': {'key': 'apiRevision', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + 'is_current': {'key': 'isCurrent', 'type': 'bool'}, + 'is_online': {'key': 'isOnline', 'type': 'bool'}, + 'api_revision_description': {'key': 'apiRevisionDescription', 'type': 'str'}, + 'api_version_description': {'key': 'apiVersionDescription', 'type': 'str'}, + 'api_version_set_id': {'key': 'apiVersionSetId', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'source_api_id': {'key': 'sourceApiId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'service_url': {'key': 'serviceUrl', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, + 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, + 'value': {'key': 'value', 'type': 'str'}, + 'format': {'key': 'format', 'type': 'str'}, + 'wsdl_selector': {'key': 'wsdlSelector', 'type': 'ApiCreateOrUpdatePropertiesWsdlSelector'}, + 'soap_api_type': {'key': 'apiType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiCreateOrUpdateProperties, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.format = kwargs.get('format', None) + self.wsdl_selector = kwargs.get('wsdl_selector', None) + self.soap_api_type = kwargs.get('soap_api_type', None) + + +class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): """Criteria to limit import of WSDL to a subset of the document. - :param wsdl_service_name: Name of service to import from WSDL + :param wsdl_service_name: Name of service to import from WSDL. :type wsdl_service_name: str - :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL + :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. :type wsdl_endpoint_name: str """ @@ -621,23 +822,25 @@ class ApiCreateOrUpdatePropertiesWsdlSelector(Model): 'wsdl_endpoint_name': {'key': 'wsdlEndpointName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiCreateOrUpdatePropertiesWsdlSelector, self).__init__(**kwargs) self.wsdl_service_name = kwargs.get('wsdl_service_name', None) self.wsdl_endpoint_name = kwargs.get('wsdl_endpoint_name', None) -class ApiExportResult(Model): +class ApiExportResult(msrest.serialization.Model): """API Export result. :param id: ResourceId of the API which was exported. :type id: str - :param export_result_format: Format in which the Api Details are exported - to the Storage Blob with Sas Key valid for 5 minutes. Possible values - include: 'Swagger', 'Wsdl', 'Wadl', 'OpenApi' - :type export_result_format: str or - ~azure.mgmt.apimanagement.models.ExportResultFormat - :param value: The object defining the schema of the exported Api Detail + :param export_result_format: Format in which the Api Details are exported to the Storage Blob + with Sas Key valid for 5 minutes. Possible values include: "swagger-link-json", "wsdl- + link+xml", "wadl-link-json", "openapi-link". + :type export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat + :param value: The object defining the schema of the exported Api Detail. :type value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ @@ -647,18 +850,21 @@ class ApiExportResult(Model): 'value': {'key': 'value', 'type': 'ApiExportResultValue'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiExportResult, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.export_result_format = kwargs.get('export_result_format', None) self.value = kwargs.get('value', None) -class ApiExportResultValue(Model): +class ApiExportResultValue(msrest.serialization.Model): """The object defining the schema of the exported Api Detail. - :param link: Link to the Storage Blob containing the result of the export - operation. The Blob Uri is only valid for 5 minutes. + :param link: Link to the Storage Blob containing the result of the export operation. The Blob + Uri is only valid for 5 minutes. :type link: str """ @@ -666,17 +872,19 @@ class ApiExportResultValue(Model): 'link': {'key': 'link', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiExportResultValue, self).__init__(**kwargs) self.link = kwargs.get('link', None) -class ApiManagementServiceApplyNetworkConfigurationParameters(Model): +class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serialization.Model): """Parameter supplied to the Apply Network configuration operation. - :param location: Location of the Api Management service to update for a - multi-region service. For a service deployed in a single region, this - parameter is not required. + :param location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. :type location: str """ @@ -684,25 +892,27 @@ class ApiManagementServiceApplyNetworkConfigurationParameters(Model): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceApplyNetworkConfigurationParameters, self).__init__(**kwargs) self.location = kwargs.get('location', None) -class ApiManagementServiceBackupRestoreParameters(Model): - """Parameters supplied to the Backup/Restore of an API Management service - operation. +class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): + """Parameters supplied to the Backup/Restore of an API Management service operation. All required parameters must be populated in order to send to Azure. - :param storage_account: Required. Azure Cloud Storage account (used to - place/retrieve the backup) name. + :param storage_account: Required. Azure Cloud Storage account (used to place/retrieve the + backup) name. :type storage_account: str - :param access_key: Required. Azure Cloud Storage account (used to - place/retrieve the backup) access key. + :param access_key: Required. Azure Cloud Storage account (used to place/retrieve the backup) + access key. :type access_key: str - :param container_name: Required. Azure Cloud Storage blob container name - used to place/retrieve the backup. + :param container_name: Required. Azure Cloud Storage blob container name used to place/retrieve + the backup. :type container_name: str :param backup_name: Required. The name of the backup file to create. :type backup_name: str @@ -722,139 +932,116 @@ class ApiManagementServiceBackupRestoreParameters(Model): 'backup_name': {'key': 'backupName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceBackupRestoreParameters, self).__init__(**kwargs) - self.storage_account = kwargs.get('storage_account', None) - self.access_key = kwargs.get('access_key', None) - self.container_name = kwargs.get('container_name', None) - self.backup_name = kwargs.get('backup_name', None) + self.storage_account = kwargs['storage_account'] + self.access_key = kwargs['access_key'] + self.container_name = kwargs['container_name'] + self.backup_name = kwargs['backup_name'] -class ApiManagementServiceBaseProperties(Model): +class ApiManagementServiceBaseProperties(msrest.serialization.Model): """Base Properties of an API Management service resource description. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param notification_sender_email: Email address from which the - notification will be sent. + :param notification_sender_email: Email address from which the notification will be sent. :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API - Management service which can be one of the following: + :ivar provisioning_state: The current provisioning state of the API Management service which + can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API - Management service, which is targeted by the long running operation - started on the service. + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :vartype created_at_utc: datetime + :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime :ivar gateway_url: Gateway URL of the API Management service. :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in - the Default Region. + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management - service. + :ivar portal_url: Publisher portal endpoint Url of the API Management service. :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API - Management service. + :ivar management_api_url: Management API endpoint URL of the API Management service. :vartype management_api_url: str :ivar scm_url: SCM endpoint URL of the API Management service. :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API - Management service. + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API - Management service. - :type hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the - API Management service in Primary region. Available only for Basic, - Standard and Premium SKU. + :param hostname_configurations: Custom hostname configuration of the API Management service. + :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of - the API Management service in Primary region which is deployed in an - Internal Virtual Network. Available only for Basic, Standard and Premium - SKU. + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the - API Management service. + :param virtual_network_configuration: Virtual network configuration of the API Management + service. :type virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API - Management service. - :type additional_locations: - list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management - service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` - will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 - and 1.2).
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` - can be used to disable just TLS 1.1.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` - can be used to disable TLS 1.0 on an API Management service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` - can be used to disable just TLS 1.1 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` - can be used to disable TLS 1.0 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can - be used to enable HTTP2 protocol on an API Management service.
Not - specifying any of these properties on PATCH operation will reset omitted - properties' values to their defaults. For all the settings except Http2 - the default value is `True` if the service was created on or before April - 1st 2018 and `False` otherwise. Http2 setting's default value is - `False`.

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, - TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, - TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:`false`. - The default value is `true` for them. Note: next ciphers can't be - disabled since they are required by Azure CloudService internal - components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384 + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the - API Management service. Max supported certificates that can be installed - is 10. - :type certificates: - list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for - Consumption SKU Service. This enforces a client certificate to be - presented on each request to the gateway. This also enables the ability to - authenticate the certificate in the policy on the gateway. Default value: - False . + :param certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service - deployed in multiple locations. This can be used to disable the gateway in - master region. Default value: False . + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management - service needs to be configured in. None (Default Value) means the API - Management service is not part of any Virtual Network, External means the - API Management deployment is set up inside a Virtual Network having an - Internet Facing Endpoint, and Internal means that API Management - deployment is setup inside a Virtual Network having an Intranet Facing - Endpoint only. Possible values include: 'None', 'External', 'Internal'. - Default value: "None" . - :type virtual_network_type: str or - ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for - the API Management service. - :type api_version_constraint: - ~azure.mgmt.apimanagement.models.ApiVersionConstraint - """ - - _validation = { - 'notification_sender_email': {'max_length': 100}, + :param virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :param api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :type restore: bool + """ + + _validation = { + 'notification_sender_email': {'max_length': 100, 'min_length': 0}, 'provisioning_state': {'readonly': True}, 'target_provisioning_state': {'readonly': True}, 'created_at_utc': {'readonly': True}, @@ -890,9 +1077,13 @@ class ApiManagementServiceBaseProperties(Model): 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, 'virtual_network_type': {'key': 'virtualNetworkType', 'type': 'str'}, 'api_version_constraint': {'key': 'apiVersionConstraint', 'type': 'ApiVersionConstraint'}, + 'restore': {'key': 'restore', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) self.notification_sender_email = kwargs.get('notification_sender_email', None) self.provisioning_state = None @@ -915,9 +1106,10 @@ def __init__(self, **kwargs): self.disable_gateway = kwargs.get('disable_gateway', False) self.virtual_network_type = kwargs.get('virtual_network_type', "None") self.api_version_constraint = kwargs.get('api_version_constraint', None) + self.restore = kwargs.get('restore', False) -class ApiManagementServiceCheckNameAvailabilityParameters(Model): +class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.Model): """Parameters supplied to the CheckNameAvailability operation. All required parameters must be populated in order to send to Azure. @@ -934,16 +1126,18 @@ class ApiManagementServiceCheckNameAvailabilityParameters(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] -class ApiManagementServiceGetSsoTokenResult(Model): +class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): """The response of the GetSsoToken operation. - :param redirect_uri: Redirect URL to the Publisher Portal containing the - SSO token. + :param redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. :type redirect_uri: str """ @@ -951,34 +1145,35 @@ class ApiManagementServiceGetSsoTokenResult(Model): 'redirect_uri': {'key': 'redirectUri', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceGetSsoTokenResult, self).__init__(**kwargs) self.redirect_uri = kwargs.get('redirect_uri', None) -class ApiManagementServiceIdentity(Model): +class ApiManagementServiceIdentity(msrest.serialization.Model): """Identity properties of the Api Management service resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of identity used for the resource. The - type 'SystemAssigned, UserAssigned' includes both an implicitly created - identity and a set of user assigned identities. The type 'None' will - remove any identities from the service. Possible values include: - 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned', 'None' + :param type: Required. The type of identity used for the resource. The type 'SystemAssigned, + UserAssigned' includes both an implicitly created identity and a set of user assigned + identities. The type 'None' will remove any identities from the service. Possible values + include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :type type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType :ivar principal_id: The principal id of the identity. :vartype principal_id: str :ivar tenant_id: The client tenant id of the identity. :vartype tenant_id: str - :param user_assigned_identities: The list of user identities associated - with the resource. The user identity + :param user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ - providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :type user_assigned_identities: dict[str, ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ @@ -996,247 +1191,193 @@ class ApiManagementServiceIdentity(Model): 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiManagementServiceIdentity, self).__init__(**kwargs) - self.type = kwargs.get('type', None) + self.type = kwargs['type'] self.principal_id = None self.tenant_id = None self.user_assigned_identities = kwargs.get('user_assigned_identities', None) -class ApiManagementServiceNameAvailabilityResult(Model): - """Response of the CheckNameAvailability operation. +class ApiManagementServiceListResult(msrest.serialization.Model): + """The response of the List API Management services operation. - Variables are only populated by the server, and will be ignored when - sending a request. + All required parameters must be populated in order to send to Azure. - :ivar name_available: True if the name is available and can be used to - create a new API Management service; otherwise false. - :vartype name_available: bool - :ivar message: If reason == invalid, provide the user with the reason why - the given name is invalid, and provide the resource naming requirements so - that the user can select a valid name. If reason == AlreadyExists, explain - that is already in use, and direct them to select a - different name. - :vartype message: str - :param reason: Invalid indicates the name provided does not match the - resource provider’s naming requirements (incorrect length, unsupported - characters, etc.) AlreadyExists indicates that the name is already in use - and is therefore unavailable. Possible values include: 'Valid', 'Invalid', - 'AlreadyExists' - :type reason: str or - ~azure.mgmt.apimanagement.models.NameAvailabilityReason + :param value: Required. Result of the List API Management services operation. + :type value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + of API Management services. + :type next_link: str """ _validation = { - 'name_available': {'readonly': True}, - 'message': {'readonly': True}, + 'value': {'required': True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'NameAvailabilityReason'}, + 'value': {'key': 'value', 'type': '[ApiManagementServiceResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) - self.name_available = None - self.message = None - self.reason = kwargs.get('reason', None) + def __init__( + self, + **kwargs + ): + super(ApiManagementServiceListResult, self).__init__(**kwargs) + self.value = kwargs['value'] + self.next_link = kwargs.get('next_link', None) -class ApimResource(Model): - """The Resource definition. +class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): + """Response of the CheckNameAvailability operation. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to - Microsoft.ApiManagement. - :vartype type: str - :param tags: Resource tags. - :type tags: dict[str, str] + :ivar name_available: True if the name is available and can be used to create a new API + Management service; otherwise false. + :vartype name_available: bool + :ivar message: If reason == invalid, provide the user with the reason why the given name is + invalid, and provide the resource naming requirements so that the user can select a valid name. + If reason == AlreadyExists, explain that :code:`` is already in use, and direct + them to select a different name. + :vartype message: str + :param reason: Invalid indicates the name provided does not match the resource provider’s + naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates + that the name is already in use and is therefore unavailable. Possible values include: "Valid", + "Invalid", "AlreadyExists". + :type reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + 'name_available': {'readonly': True}, + 'message': {'readonly': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, } - def __init__(self, **kwargs): - super(ApimResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.tags = kwargs.get('tags', None) + def __init__( + self, + **kwargs + ): + super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) + self.name_available = None + self.message = None + self.reason = kwargs.get('reason', None) -class ApiManagementServiceResource(ApimResource): - """A single API Management service resource in List or Get response. +class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): + """Properties of an API Management service resource description. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource is set to - Microsoft.ApiManagement. - :vartype type: str - :param tags: Resource tags. - :type tags: dict[str, str] - :param notification_sender_email: Email address from which the - notification will be sent. + :param notification_sender_email: Email address from which the notification will be sent. :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API - Management service which can be one of the following: + :ivar provisioning_state: The current provisioning state of the API Management service which + can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API - Management service, which is targeted by the long running operation - started on the service. + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :vartype created_at_utc: datetime + :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime :ivar gateway_url: Gateway URL of the API Management service. :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in - the Default Region. + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management - service. + :ivar portal_url: Publisher portal endpoint Url of the API Management service. :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API - Management service. + :ivar management_api_url: Management API endpoint URL of the API Management service. :vartype management_api_url: str :ivar scm_url: SCM endpoint URL of the API Management service. :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API - Management service. + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API - Management service. - :type hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the - API Management service in Primary region. Available only for Basic, - Standard and Premium SKU. + :param hostname_configurations: Custom hostname configuration of the API Management service. + :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of - the API Management service in Primary region which is deployed in an - Internal Virtual Network. Available only for Basic, Standard and Premium - SKU. + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the - API Management service. + :param virtual_network_configuration: Virtual network configuration of the API Management + service. :type virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API - Management service. - :type additional_locations: - list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management - service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` - will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 - and 1.2).
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` - can be used to disable just TLS 1.1.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` - can be used to disable TLS 1.0 on an API Management service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` - can be used to disable just TLS 1.1 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` - can be used to disable TLS 1.0 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can - be used to enable HTTP2 protocol on an API Management service.
Not - specifying any of these properties on PATCH operation will reset omitted - properties' values to their defaults. For all the settings except Http2 - the default value is `True` if the service was created on or before April - 1st 2018 and `False` otherwise. Http2 setting's default value is - `False`.

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

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

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

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

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

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :type custom_properties: dict[str, str] + :param certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :type enable_client_certificate: bool + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. + :type disable_gateway: bool + :param virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :param api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :type restore: bool + :param publisher_email: Publisher email. + :type publisher_email: str + :param publisher_name: Publisher name. + :type publisher_name: str + """ + + _validation = { + 'notification_sender_email': {'max_length': 100, 'min_length': 0}, + 'provisioning_state': {'readonly': True}, + 'target_provisioning_state': {'readonly': True}, + 'created_at_utc': {'readonly': True}, + 'gateway_url': {'readonly': True}, + 'gateway_regional_url': {'readonly': True}, + 'portal_url': {'readonly': True}, + 'management_api_url': {'readonly': True}, + 'scm_url': {'readonly': True}, + 'developer_portal_url': {'readonly': True}, + 'public_ip_addresses': {'readonly': True}, + 'private_ip_addresses': {'readonly': True}, + 'publisher_email': {'max_length': 100, 'min_length': 0}, + 'publisher_name': {'max_length': 100, 'min_length': 0}, + } + + _attribute_map = { + 'notification_sender_email': {'key': 'notificationSenderEmail', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'target_provisioning_state': {'key': 'targetProvisioningState', 'type': 'str'}, + 'created_at_utc': {'key': 'createdAtUtc', 'type': 'iso-8601'}, + 'gateway_url': {'key': 'gatewayUrl', 'type': 'str'}, + 'gateway_regional_url': {'key': 'gatewayRegionalUrl', 'type': 'str'}, + 'portal_url': {'key': 'portalUrl', 'type': 'str'}, + 'management_api_url': {'key': 'managementApiUrl', 'type': 'str'}, + 'scm_url': {'key': 'scmUrl', 'type': 'str'}, + 'developer_portal_url': {'key': 'developerPortalUrl', 'type': 'str'}, + 'hostname_configurations': {'key': 'hostnameConfigurations', 'type': '[HostnameConfiguration]'}, + 'public_ip_addresses': {'key': 'publicIPAddresses', 'type': '[str]'}, + 'private_ip_addresses': {'key': 'privateIPAddresses', 'type': '[str]'}, + 'virtual_network_configuration': {'key': 'virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, + 'additional_locations': {'key': 'additionalLocations', 'type': '[AdditionalLocation]'}, + 'custom_properties': {'key': 'customProperties', 'type': '{str}'}, + 'certificates': {'key': 'certificates', 'type': '[CertificateConfiguration]'}, + 'enable_client_certificate': {'key': 'enableClientCertificate', 'type': 'bool'}, + 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, + 'virtual_network_type': {'key': 'virtualNetworkType', 'type': 'str'}, + 'api_version_constraint': {'key': 'apiVersionConstraint', 'type': 'ApiVersionConstraint'}, + 'restore': {'key': 'restore', 'type': 'bool'}, + 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, + 'publisher_name': {'key': 'publisherName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiManagementServiceUpdateProperties, self).__init__(**kwargs) + self.publisher_email = kwargs.get('publisher_email', None) + self.publisher_name = kwargs.get('publisher_name', None) + + +class ApiReleaseCollection(msrest.serialization.Model): + """Paged ApiRelease list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiReleaseContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiReleaseCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None class ApiReleaseContract(Resource): """ApiRelease details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -1591,13 +2117,12 @@ class ApiReleaseContract(Resource): :vartype type: str :param api_id: Identifier of the API the release belongs to. :type api_id: str - :ivar created_date_time: The time the API was released. The date conforms - to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 - standard. - :vartype created_date_time: datetime + :ivar created_date_time: The time the API was released. The date conforms to the following + format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime :ivar updated_date_time: The time the API release was updated. - :vartype updated_date_time: datetime - :param notes: Release Notes + :vartype updated_date_time: ~datetime.datetime + :param notes: Release Notes. :type notes: str """ @@ -1619,7 +2144,10 @@ class ApiReleaseContract(Resource): 'notes': {'key': 'properties.notes', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiReleaseContract, self).__init__(**kwargs) self.api_id = kwargs.get('api_id', None) self.created_date_time = None @@ -1627,24 +2155,51 @@ def __init__(self, **kwargs): self.notes = kwargs.get('notes', None) -class ApiRevisionContract(Model): +class ApiRevisionCollection(msrest.serialization.Model): + """Paged Api Revision list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiRevisionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiRevisionCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ApiRevisionContract(msrest.serialization.Model): """Summary of revision metadata. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar api_id: Identifier of the API Revision. :vartype api_id: str :ivar api_revision: Revision number of API. :vartype api_revision: str - :ivar created_date_time: The time the API Revision was created. The date - conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the - ISO 8601 standard. - :vartype created_date_time: datetime - :ivar updated_date_time: The time the API Revision were updated. The date - conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the - ISO 8601 standard. - :vartype updated_date_time: datetime + :ivar created_date_time: The time the API Revision was created. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime + :ivar updated_date_time: The time the API Revision were updated. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype updated_date_time: ~datetime.datetime :ivar description: Description of the API Revision. :vartype description: str :ivar private_url: Gateway URL for accessing the non-current API Revision. @@ -1660,7 +2215,7 @@ class ApiRevisionContract(Model): 'api_revision': {'readonly': True, 'max_length': 100, 'min_length': 1}, 'created_date_time': {'readonly': True}, 'updated_date_time': {'readonly': True}, - 'description': {'readonly': True, 'max_length': 256}, + 'description': {'readonly': True, 'max_length': 256, 'min_length': 0}, 'private_url': {'readonly': True}, 'is_online': {'readonly': True}, 'is_current': {'readonly': True}, @@ -1677,7 +2232,10 @@ class ApiRevisionContract(Model): 'is_current': {'key': 'isCurrent', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiRevisionContract, self).__init__(**kwargs) self.api_id = None self.api_revision = None @@ -1689,25 +2247,22 @@ def __init__(self, **kwargs): self.is_current = None -class ApiRevisionInfoContract(Model): - """Object used to create an API Revision or Version based on an existing API - Revision. +class ApiRevisionInfoContract(msrest.serialization.Model): + """Object used to create an API Revision or Version based on an existing API Revision. - :param source_api_id: Resource identifier of API to be used to create the - revision from. + :param source_api_id: Resource identifier of API to be used to create the revision from. :type source_api_id: str :param api_version_name: Version identifier for the new API Version. :type api_version_name: str :param api_revision_description: Description of new API Revision. :type api_revision_description: str - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { - 'api_version_name': {'max_length': 100}, - 'api_revision_description': {'max_length': 256}, + 'api_version_name': {'max_length': 100, 'min_length': 0}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -1717,7 +2272,10 @@ class ApiRevisionInfoContract(Model): 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiRevisionInfoContract, self).__init__(**kwargs) self.source_api_id = kwargs.get('source_api_id', None) self.api_version_name = kwargs.get('api_version_name', None) @@ -1728,27 +2286,21 @@ def __init__(self, **kwargs): class ApiTagResourceContractProperties(ApiEntityBaseContract): """API contract properties for the Tag Resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -1758,35 +2310,31 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param id: API identifier in the form /apis/{apiId}. :type id: str :param name: API name. :type name: str - :param service_url: Absolute URL of the backend service implementing this - API. + :param service_url: Absolute URL of the backend service implementing this API. :type service_url: str - :param path: Relative URL uniquely identifying this API and all of its - resource paths within the API Management service instance. It is appended - to the API endpoint base URL specified during the service instance - creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 1}, 'path': {'max_length': 400, 'min_length': 0}, @@ -1809,10 +2357,13 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): 'name': {'key': 'name', 'type': 'str'}, 'service_url': {'key': 'serviceUrl', 'type': 'str'}, 'path': {'key': 'path', 'type': 'str'}, - 'protocols': {'key': 'protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiTagResourceContractProperties, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -1821,30 +2372,24 @@ def __init__(self, **kwargs): self.protocols = kwargs.get('protocols', None) -class ApiUpdateContract(Model): +class ApiUpdateContract(msrest.serialization.Model): """API update contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -1854,33 +2399,29 @@ class ApiUpdateContract(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param display_name: API name. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. + :param service_url: Absolute URL of the backend service implementing this API. :type service_url: str - :param path: Relative URL uniquely identifying this API and all of its - resource paths within the API Management service instance. It is appended - to the API endpoint base URL specified during the service instance - creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 1}, 'path': {'max_length': 400, 'min_length': 0}, @@ -1902,10 +2443,13 @@ class ApiUpdateContract(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiUpdateContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authentication_settings = kwargs.get('authentication_settings', None) @@ -1925,11 +2469,11 @@ def __init__(self, **kwargs): self.protocols = kwargs.get('protocols', None) -class ApiVersionConstraint(Model): +class ApiVersionConstraint(msrest.serialization.Model): """Control Plane Apis version constraint for the API Management service. - :param min_api_version: Limit control plane API calls to API Management - service with version equal to or newer than this value. + :param min_api_version: Limit control plane API calls to API Management service with version + equal to or newer than this value. :type min_api_version: str """ @@ -1937,18 +2481,41 @@ class ApiVersionConstraint(Model): 'min_api_version': {'key': 'minApiVersion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiVersionConstraint, self).__init__(**kwargs) self.min_api_version = kwargs.get('min_api_version', None) +class ApiVersionSetCollection(msrest.serialization.Model): + """Paged Api Version Set list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiVersionSetContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiVersionSetCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class ApiVersionSetContract(Resource): """Api Version Set Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -1958,19 +2525,17 @@ class ApiVersionSetContract(Resource): :vartype type: str :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str - :param display_name: Required. Name of API Version Set + :param display_name: Name of API Version Set. :type display_name: str - :param versioning_scheme: Required. An value that determines where the API - Version identifer will be located in a HTTP request. Possible values - include: 'Segment', 'Query', 'Header' - :type versioning_scheme: str or - ~azure.mgmt.apimanagement.models.VersioningScheme + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -1979,8 +2544,7 @@ class ApiVersionSetContract(Resource): 'type': {'readonly': True}, 'version_query_name': {'max_length': 100, 'min_length': 1}, 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, - 'versioning_scheme': {'required': True}, + 'display_name': {'max_length': 100, 'min_length': 1}, } _attribute_map = { @@ -1994,7 +2558,10 @@ class ApiVersionSetContract(Resource): 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiVersionSetContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.version_query_name = kwargs.get('version_query_name', None) @@ -2003,26 +2570,25 @@ def __init__(self, **kwargs): self.versioning_scheme = kwargs.get('versioning_scheme', None) -class ApiVersionSetContractDetails(Model): - """An API Version Set contains the common configuration for a set of API - Versions relating . +class ApiVersionSetContractDetails(msrest.serialization.Model): + """An API Version Set contains the common configuration for a set of API Versions relating. - :param id: Identifier for existing API Version Set. Omit this value to - create a new Version Set. + :param id: Identifier for existing API Version Set. Omit this value to create a new Version + Set. :type id: str :param name: The display Name of the API Version Set. :type name: str :param description: Description of API Version Set. :type description: str - :param versioning_scheme: An value that determines where the API Version - identifer will be located in a HTTP request. Possible values include: - 'Segment', 'Query', 'Header' - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.enum - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str """ @@ -2035,7 +2601,10 @@ class ApiVersionSetContractDetails(Model): 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiVersionSetContractDetails, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -2045,55 +2614,100 @@ def __init__(self, **kwargs): self.version_header_name = kwargs.get('version_header_name', None) -class ApiVersionSetEntityBase(Model): +class ApiVersionSetEntityBase(msrest.serialization.Model): """Api Version set base parameters. :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :type version_query_name: str + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :type version_header_name: str + """ + + _validation = { + 'version_query_name': {'max_length': 100, 'min_length': 1}, + 'version_header_name': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, + 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiVersionSetEntityBase, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.version_query_name = kwargs.get('version_query_name', None) + self.version_header_name = kwargs.get('version_header_name', None) + + +class ApiVersionSetContractProperties(ApiVersionSetEntityBase): + """Properties of an API Version Set. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of API Version Set. + :type description: str + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str + :param display_name: Required. Name of API Version Set. + :type display_name: str + :param versioning_scheme: Required. An value that determines where the API Version identifer + will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { 'version_query_name': {'max_length': 100, 'min_length': 1}, 'version_header_name': {'max_length': 100, 'min_length': 1}, + 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'versioning_scheme': {'required': True}, } _attribute_map = { 'description': {'key': 'description', 'type': 'str'}, 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, } - def __init__(self, **kwargs): - super(ApiVersionSetEntityBase, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.version_query_name = kwargs.get('version_query_name', None) - self.version_header_name = kwargs.get('version_header_name', None) + def __init__( + self, + **kwargs + ): + super(ApiVersionSetContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.versioning_scheme = kwargs['versioning_scheme'] -class ApiVersionSetUpdateParameters(Model): +class ApiVersionSetUpdateParameters(msrest.serialization.Model): """Parameters to update or create an Api Version Set Contract. :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str - :param display_name: Name of API Version Set + :param display_name: Name of API Version Set. :type display_name: str - :param versioning_scheme: An value that determines where the API Version - identifer will be located in a HTTP request. Possible values include: - 'Segment', 'Query', 'Header' - :type versioning_scheme: str or - ~azure.mgmt.apimanagement.models.VersioningScheme + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -2110,7 +2724,10 @@ class ApiVersionSetUpdateParameters(Model): 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.version_query_name = kwargs.get('version_query_name', None) @@ -2119,11 +2736,51 @@ def __init__(self, **kwargs): self.versioning_scheme = kwargs.get('versioning_scheme', None) +class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): + """Properties used to create or update an API Version Set. + + :param description: Description of API Version Set. + :type description: str + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :type version_query_name: str + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :type version_header_name: str + :param display_name: Name of API Version Set. + :type display_name: str + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ + + _validation = { + 'version_query_name': {'max_length': 100, 'min_length': 1}, + 'version_header_name': {'max_length': 100, 'min_length': 1}, + 'display_name': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, + 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiVersionSetUpdateParametersProperties, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.versioning_scheme = kwargs.get('versioning_scheme', None) + + class AssociationContract(Resource): """Association entity details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2131,39 +2788,40 @@ class AssociationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param provisioning_state: Provisioning state. Possible values include: - 'created' - :type provisioning_state: str or - ~azure.mgmt.apimanagement.models.ProvisioningState + :ivar provisioning_state: Provisioning state. Default value: "created". + :vartype provisioning_state: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'provisioning_state': {'constant': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, **kwargs): + provisioning_state = "created" + + def __init__( + self, + **kwargs + ): super(AssociationContract, self).__init__(**kwargs) - self.provisioning_state = kwargs.get('provisioning_state', None) -class AuthenticationSettingsContract(Model): +class AuthenticationSettingsContract(msrest.serialization.Model): """API Authentication Settings. - :param o_auth2: OAuth2 Authentication settings - :type o_auth2: - ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :param openid: OpenID Connect Authentication Settings - :type openid: - ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :param o_auth2: OAuth2 Authentication settings. + :type o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract + :param openid: OpenID Connect Authentication Settings. + :type openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract """ _attribute_map = { @@ -2171,19 +2829,46 @@ class AuthenticationSettingsContract(Model): 'openid': {'key': 'openid', 'type': 'OpenIdAuthenticationSettingsContract'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AuthenticationSettingsContract, self).__init__(**kwargs) self.o_auth2 = kwargs.get('o_auth2', None) self.openid = kwargs.get('openid', None) +class AuthorizationServerCollection(msrest.serialization.Model): + """Paged OAuth2 Authorization Servers list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AuthorizationServerContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AuthorizationServerCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + self.next_link = kwargs.get('next_link', None) + + class AuthorizationServerContract(Resource): """External OAuth authorization server settings. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2191,67 +2876,58 @@ class AuthorizationServerContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str - :param display_name: Required. User-friendly authorization server name. + :param display_name: User-friendly authorization server name. :type display_name: str - :param client_registration_endpoint: Required. Optional reference to a - page where client or app registration for this authorization server is - performed. Contains absolute URL to entity being referenced. + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. :type client_registration_endpoint: str - :param authorization_endpoint: Required. OAuth authorization endpoint. See + :param authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. :type authorization_endpoint: str - :param grant_types: Required. Form of an authorization grant, which the - client uses to request the access token. + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Required. Client or app id registered with this - authorization server. + :param client_id: Client or app id registered with this authorization server. :type client_id: str - :param client_secret: Client or app secret registered with this - authorization server. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. :type client_secret: str """ @@ -2259,11 +2935,7 @@ class AuthorizationServerContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 50, 'min_length': 1}, - 'client_registration_endpoint': {'required': True}, - 'authorization_endpoint': {'required': True}, - 'grant_types': {'required': True}, - 'client_id': {'required': True}, + 'display_name': {'max_length': 50, 'min_length': 1}, } _attribute_map = { @@ -2271,7 +2943,7 @@ class AuthorizationServerContract(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, @@ -2288,7 +2960,10 @@ class AuthorizationServerContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AuthorizationServerContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authorization_methods = kwargs.get('authorization_methods', None) @@ -2308,57 +2983,49 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) -class AuthorizationServerContractBaseProperties(Model): +class AuthorizationServerContractBaseProperties(msrest.serialization.Model): """External OAuth authorization server Update settings contract. - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str """ _attribute_map = { 'description': {'key': 'description', 'type': 'str'}, - 'authorization_methods': {'key': 'authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, @@ -2369,7 +3036,10 @@ class AuthorizationServerContractBaseProperties(Model): 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AuthorizationServerContractBaseProperties, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authorization_methods = kwargs.get('authorization_methods', None) @@ -2383,11 +3053,139 @@ def __init__(self, **kwargs): self.resource_owner_password = kwargs.get('resource_owner_password', None) +class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): + """External OAuth authorization server settings Properties. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of the authorization server. Can contain HTML formatting tags. + :type description: str + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :type client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :type token_endpoint: str + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :type support_state: bool + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. + :type default_scope: str + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :type bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + :param display_name: Required. User-friendly authorization server name. + :type display_name: str + :param client_registration_endpoint: Required. Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :type client_registration_endpoint: str + :param authorization_endpoint: Required. OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :type authorization_endpoint: str + :param grant_types: Required. Form of an authorization grant, which the client uses to request + the access token. + :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :param client_id: Required. Client or app id registered with this authorization server. + :type client_id: str + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :type client_secret: str + """ + + _validation = { + 'display_name': {'required': True, 'max_length': 50, 'min_length': 1}, + 'client_registration_endpoint': {'required': True}, + 'authorization_endpoint': {'required': True}, + 'grant_types': {'required': True}, + 'client_id': {'required': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, + 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, + 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, + 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, + 'support_state': {'key': 'supportState', 'type': 'bool'}, + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, + 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, + 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AuthorizationServerContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.client_registration_endpoint = kwargs['client_registration_endpoint'] + self.authorization_endpoint = kwargs['authorization_endpoint'] + self.grant_types = kwargs['grant_types'] + self.client_id = kwargs['client_id'] + self.client_secret = kwargs.get('client_secret', None) + + +class AuthorizationServerSecretsContract(msrest.serialization.Model): + """OAuth Server Secrets Contract. + + :param client_secret: oAuth Authorization Server Secrets. + :type client_secret: str + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + """ + + _attribute_map = { + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AuthorizationServerSecretsContract, self).__init__(**kwargs) + self.client_secret = kwargs.get('client_secret', None) + self.resource_owner_username = kwargs.get('resource_owner_username', None) + self.resource_owner_password = kwargs.get('resource_owner_password', None) + + class AuthorizationServerUpdateContract(Resource): """External OAuth authorization server settings. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2395,67 +3193,58 @@ class AuthorizationServerUpdateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str :param display_name: User-friendly authorization server name. :type display_name: str - :param client_registration_endpoint: Optional reference to a page where - client or app registration for this authorization server is performed. - Contains absolute URL to entity being referenced. + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. :type client_registration_endpoint: str :param authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses - to request the access token. + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization - server. + :param client_id: Client or app id registered with this authorization server. :type client_id: str - :param client_secret: Client or app secret registered with this - authorization server. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. :type client_secret: str """ @@ -2471,7 +3260,7 @@ class AuthorizationServerUpdateContract(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, @@ -2488,7 +3277,10 @@ class AuthorizationServerUpdateContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(AuthorizationServerUpdateContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.authorization_methods = kwargs.get('authorization_methods', None) @@ -2508,7 +3300,101 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) -class BackendAuthorizationHeaderCredentials(Model): +class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBaseProperties): + """External OAuth authorization server Update settings contract. + + :param description: Description of the authorization server. Can contain HTML formatting tags. + :type description: str + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :type client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :type token_endpoint: str + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :type support_state: bool + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. + :type default_scope: str + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :type bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + :param display_name: User-friendly authorization server name. + :type display_name: str + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :type client_registration_endpoint: str + :param authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :type authorization_endpoint: str + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. + :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :param client_id: Client or app id registered with this authorization server. + :type client_id: str + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :type client_secret: str + """ + + _validation = { + 'display_name': {'max_length': 50, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, + 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, + 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, + 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, + 'support_state': {'key': 'supportState', 'type': 'bool'}, + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, + 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, + 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AuthorizationServerUpdateContractProperties, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.client_registration_endpoint = kwargs.get('client_registration_endpoint', None) + self.authorization_endpoint = kwargs.get('authorization_endpoint', None) + self.grant_types = kwargs.get('grant_types', None) + self.client_id = kwargs.get('client_id', None) + self.client_secret = kwargs.get('client_secret', None) + + +class BackendAuthorizationHeaderCredentials(msrest.serialization.Model): """Authorization header information. All required parameters must be populated in order to send to Azure. @@ -2529,31 +3415,32 @@ class BackendAuthorizationHeaderCredentials(Model): 'parameter': {'key': 'parameter', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendAuthorizationHeaderCredentials, self).__init__(**kwargs) - self.scheme = kwargs.get('scheme', None) - self.parameter = kwargs.get('parameter', None) + self.scheme = kwargs['scheme'] + self.parameter = kwargs['parameter'] -class BackendBaseParameters(Model): +class BackendBaseParameters(msrest.serialization.Model): """Backend entity base Parameter set. :param title: Backend Title. :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ @@ -2573,7 +3460,10 @@ class BackendBaseParameters(Model): 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendBaseParameters, self).__init__(**kwargs) self.title = kwargs.get('title', None) self.description = kwargs.get('description', None) @@ -2584,13 +3474,33 @@ def __init__(self, **kwargs): self.tls = kwargs.get('tls', None) +class BackendCollection(msrest.serialization.Model): + """Paged Backend list representation. + + :param value: Backend values. + :type value: list[~azure.mgmt.apimanagement.models.BackendContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BackendContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BackendCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class BackendContract(Resource): """Backend details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2602,23 +3512,20 @@ class BackendContract(Resource): :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Required. Runtime Url of the Backend. + :param url: Runtime Url of the Backend. :type url: str - :param protocol: Required. Backend communication protocol. Possible values - include: 'http', 'soap' + :param protocol: Backend communication protocol. Possible values include: "http", "soap". :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ @@ -2629,8 +3536,7 @@ class BackendContract(Resource): 'title': {'max_length': 300, 'min_length': 1}, 'description': {'max_length': 2000, 'min_length': 1}, 'resource_id': {'max_length': 2000, 'min_length': 1}, - 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, - 'protocol': {'required': True}, + 'url': {'max_length': 2000, 'min_length': 1}, } _attribute_map = { @@ -2648,20 +3554,79 @@ class BackendContract(Resource): 'protocol': {'key': 'properties.protocol', 'type': 'str'}, } - def __init__(self, **kwargs): - super(BackendContract, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.description = kwargs.get('description', None) - self.resource_id = kwargs.get('resource_id', None) - self.properties = kwargs.get('properties', None) - self.credentials = kwargs.get('credentials', None) - self.proxy = kwargs.get('proxy', None) - self.tls = kwargs.get('tls', None) - self.url = kwargs.get('url', None) - self.protocol = kwargs.get('protocol', None) + def __init__( + self, + **kwargs + ): + super(BackendContract, self).__init__(**kwargs) + self.title = kwargs.get('title', None) + self.description = kwargs.get('description', None) + self.resource_id = kwargs.get('resource_id', None) + self.properties = kwargs.get('properties', None) + self.credentials = kwargs.get('credentials', None) + self.proxy = kwargs.get('proxy', None) + self.tls = kwargs.get('tls', None) + self.url = kwargs.get('url', None) + self.protocol = kwargs.get('protocol', None) + + +class BackendContractProperties(BackendBaseParameters): + """Parameters supplied to the Create Backend operation. + + All required parameters must be populated in order to send to Azure. + + :param title: Backend Title. + :type title: str + :param description: Backend Description. + :type description: str + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. + :type resource_id: str + :param properties: Backend Properties contract. + :type properties: ~azure.mgmt.apimanagement.models.BackendProperties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. + :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :param tls: Backend TLS Properties. + :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :param url: Required. Runtime Url of the Backend. + :type url: str + :param protocol: Required. Backend communication protocol. Possible values include: "http", + "soap". + :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + _validation = { + 'title': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 2000, 'min_length': 1}, + 'resource_id': {'max_length': 2000, 'min_length': 1}, + 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, + 'protocol': {'required': True}, + } + + _attribute_map = { + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BackendProperties'}, + 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, + 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, + 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, + 'url': {'key': 'url', 'type': 'str'}, + 'protocol': {'key': 'protocol', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BackendContractProperties, self).__init__(**kwargs) + self.url = kwargs['url'] + self.protocol = kwargs['protocol'] -class BackendCredentialsContract(Model): +class BackendCredentialsContract(msrest.serialization.Model): """Details of the Credentials used to connect to Backend. :param certificate: List of Client Certificate Thumbprint. @@ -2670,13 +3635,12 @@ class BackendCredentialsContract(Model): :type query: dict[str, list[str]] :param header: Header Parameter description. :type header: dict[str, list[str]] - :param authorization: Authorization header authentication - :type authorization: - ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials + :param authorization: Authorization header authentication. + :type authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ _validation = { - 'certificate': {'max_items': 32}, + 'certificate': {'max_items': 32, 'min_items': 0}, } _attribute_map = { @@ -2686,7 +3650,10 @@ class BackendCredentialsContract(Model): 'authorization': {'key': 'authorization', 'type': 'BackendAuthorizationHeaderCredentials'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendCredentialsContract, self).__init__(**kwargs) self.certificate = kwargs.get('certificate', None) self.query = kwargs.get('query', None) @@ -2694,10 +3661,10 @@ def __init__(self, **kwargs): self.authorization = kwargs.get('authorization', None) -class BackendProperties(Model): +class BackendProperties(msrest.serialization.Model): """Properties specific to the Backend Type. - :param service_fabric_cluster: Backend Service Fabric Cluster Properties + :param service_fabric_cluster: Backend Service Fabric Cluster Properties. :type service_fabric_cluster: ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ @@ -2706,23 +3673,25 @@ class BackendProperties(Model): 'service_fabric_cluster': {'key': 'serviceFabricCluster', 'type': 'BackendServiceFabricClusterProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendProperties, self).__init__(**kwargs) self.service_fabric_cluster = kwargs.get('service_fabric_cluster', None) -class BackendProxyContract(Model): +class BackendProxyContract(msrest.serialization.Model): """Details of the Backend WebProxy Server to use in the Request to Backend. All required parameters must be populated in order to send to Azure. - :param url: Required. WebProxy Server AbsoluteUri property which includes - the entire URI stored in the Uri instance, including all fragments and - query strings. + :param url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored + in the Uri instance, including all fragments and query strings. :type url: str - :param username: Username to connect to the WebProxy server + :param username: Username to connect to the WebProxy server. :type username: str - :param password: Password to connect to the WebProxy Server + :param password: Password to connect to the WebProxy Server. :type password: str """ @@ -2736,9 +3705,12 @@ class BackendProxyContract(Model): 'password': {'key': 'password', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendProxyContract, self).__init__(**kwargs) - self.url = kwargs.get('url', None) + self.url = kwargs['url'] self.username = kwargs.get('username', None) self.password = kwargs.get('password', None) @@ -2746,8 +3718,7 @@ def __init__(self, **kwargs): class BackendReconnectContract(Resource): """Reconnect request parameters. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2755,9 +3726,9 @@ class BackendReconnectContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param after: Duration in ISO8601 format after which reconnect will be - initiated. Minimum duration of the Reconnect is PT2M. - :type after: timedelta + :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + duration of the Reconnect is PT2M. + :type after: ~datetime.timedelta """ _validation = { @@ -2773,30 +3744,32 @@ class BackendReconnectContract(Resource): 'after': {'key': 'properties.after', 'type': 'duration'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendReconnectContract, self).__init__(**kwargs) self.after = kwargs.get('after', None) -class BackendServiceFabricClusterProperties(Model): +class BackendServiceFabricClusterProperties(msrest.serialization.Model): """Properties of the Service Fabric Type Backend. All required parameters must be populated in order to send to Azure. - :param client_certificatethumbprint: Required. The client certificate - thumbprint for the management endpoint. + :param client_certificatethumbprint: Required. The client certificate thumbprint for the + management endpoint. :type client_certificatethumbprint: str - :param max_partition_resolution_retries: Maximum number of retries while - attempting resolve the partition. + :param max_partition_resolution_retries: Maximum number of retries while attempting resolve the + partition. :type max_partition_resolution_retries: int :param management_endpoints: Required. The cluster management endpoint. :type management_endpoints: list[str] - :param server_certificate_thumbprints: Thumbprints of certificates cluster - management service uses for tls communication + :param server_certificate_thumbprints: Thumbprints of certificates cluster management service + uses for tls communication. :type server_certificate_thumbprints: list[str] - :param server_x509_names: Server X509 Certificate Names Collection - :type server_x509_names: - list[~azure.mgmt.apimanagement.models.X509CertificateName] + :param server_x509_names: Server X509 Certificate Names Collection. + :type server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ _validation = { @@ -2812,25 +3785,26 @@ class BackendServiceFabricClusterProperties(Model): 'server_x509_names': {'key': 'serverX509Names', 'type': '[X509CertificateName]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) - self.client_certificatethumbprint = kwargs.get('client_certificatethumbprint', None) + self.client_certificatethumbprint = kwargs['client_certificatethumbprint'] self.max_partition_resolution_retries = kwargs.get('max_partition_resolution_retries', None) - self.management_endpoints = kwargs.get('management_endpoints', None) + self.management_endpoints = kwargs['management_endpoints'] self.server_certificate_thumbprints = kwargs.get('server_certificate_thumbprints', None) self.server_x509_names = kwargs.get('server_x509_names', None) -class BackendTlsProperties(Model): +class BackendTlsProperties(msrest.serialization.Model): """Properties controlling TLS Certificate Validation. - :param validate_certificate_chain: Flag indicating whether SSL certificate - chain validation should be done when using self-signed certificates for - this backend host. Default value: True . + :param validate_certificate_chain: Flag indicating whether SSL certificate chain validation + should be done when using self-signed certificates for this backend host. :type validate_certificate_chain: bool - :param validate_certificate_name: Flag indicating whether SSL certificate - name validation should be done when using self-signed certificates for - this backend host. Default value: True . + :param validate_certificate_name: Flag indicating whether SSL certificate name validation + should be done when using self-signed certificates for this backend host. :type validate_certificate_name: bool """ @@ -2839,36 +3813,88 @@ class BackendTlsProperties(Model): 'validate_certificate_name': {'key': 'validateCertificateName', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendTlsProperties, self).__init__(**kwargs) self.validate_certificate_chain = kwargs.get('validate_certificate_chain', True) self.validate_certificate_name = kwargs.get('validate_certificate_name', True) -class BackendUpdateParameters(Model): +class BackendUpdateParameterProperties(BackendBaseParameters): + """Parameters supplied to the Update Backend operation. + + :param title: Backend Title. + :type title: str + :param description: Backend Description. + :type description: str + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. + :type resource_id: str + :param properties: Backend Properties contract. + :type properties: ~azure.mgmt.apimanagement.models.BackendProperties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. + :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :param tls: Backend TLS Properties. + :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :param url: Runtime Url of the Backend. + :type url: str + :param protocol: Backend communication protocol. Possible values include: "http", "soap". + :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + _validation = { + 'title': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 2000, 'min_length': 1}, + 'resource_id': {'max_length': 2000, 'min_length': 1}, + 'url': {'max_length': 2000, 'min_length': 1}, + } + + _attribute_map = { + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BackendProperties'}, + 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, + 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, + 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, + 'url': {'key': 'url', 'type': 'str'}, + 'protocol': {'key': 'protocol', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(BackendUpdateParameterProperties, self).__init__(**kwargs) + self.url = kwargs.get('url', None) + self.protocol = kwargs.get('protocol', None) + + +class BackendUpdateParameters(msrest.serialization.Model): """Backend update parameters. :param title: Backend Title. :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :param url: Runtime Url of the Backend. :type url: str - :param protocol: Backend communication protocol. Possible values include: - 'http', 'soap' + :param protocol: Backend communication protocol. Possible values include: "http", "soap". :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ @@ -2891,7 +3917,10 @@ class BackendUpdateParameters(Model): 'protocol': {'key': 'properties.protocol', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BackendUpdateParameters, self).__init__(**kwargs) self.title = kwargs.get('title', None) self.description = kwargs.get('description', None) @@ -2904,7 +3933,7 @@ def __init__(self, **kwargs): self.protocol = kwargs.get('protocol', None) -class BodyDiagnosticSettings(Model): +class BodyDiagnosticSettings(msrest.serialization.Model): """Body logging settings. :param bytes: Number of request body bytes to log. @@ -2919,18 +3948,41 @@ class BodyDiagnosticSettings(Model): 'bytes': {'key': 'bytes', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(BodyDiagnosticSettings, self).__init__(**kwargs) self.bytes = kwargs.get('bytes', None) +class CacheCollection(msrest.serialization.Model): + """Paged Caches list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.CacheContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CacheContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CacheCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class CacheContract(Resource): """Cache details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2938,12 +3990,14 @@ class CacheContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Cache description + :param description: Cache description. :type description: str - :param connection_string: Required. Runtime connection string to cache + :param connection_string: Runtime connection string to cache. :type connection_string: str - :param resource_id: Original uri of entity in external system cache points - to + :param use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). + :type use_from_location: str + :param resource_id: Original uri of entity in external system cache points to. :type resource_id: str """ @@ -2951,9 +4005,10 @@ class CacheContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 2000}, - 'connection_string': {'required': True, 'max_length': 300}, - 'resource_id': {'max_length': 2000}, + 'description': {'max_length': 2000, 'min_length': 0}, + 'connection_string': {'max_length': 300, 'min_length': 0}, + 'use_from_location': {'max_length': 256, 'min_length': 0}, + 'resource_id': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { @@ -2962,50 +4017,85 @@ class CacheContract(Resource): 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, + 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CacheContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.connection_string = kwargs.get('connection_string', None) + self.use_from_location = kwargs.get('use_from_location', None) self.resource_id = kwargs.get('resource_id', None) -class CacheUpdateParameters(Model): +class CacheUpdateParameters(msrest.serialization.Model): """Cache update details. - :param description: Cache description + :param description: Cache description. :type description: str - :param connection_string: Runtime connection string to cache + :param connection_string: Runtime connection string to cache. :type connection_string: str - :param resource_id: Original uri of entity in external system cache points - to + :param use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). + :type use_from_location: str + :param resource_id: Original uri of entity in external system cache points to. :type resource_id: str """ _validation = { - 'description': {'max_length': 2000}, - 'connection_string': {'max_length': 300}, - 'resource_id': {'max_length': 2000}, + 'description': {'max_length': 2000, 'min_length': 0}, + 'connection_string': {'max_length': 300, 'min_length': 0}, + 'use_from_location': {'max_length': 256, 'min_length': 0}, + 'resource_id': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { 'description': {'key': 'properties.description', 'type': 'str'}, 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, + 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CacheUpdateParameters, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.connection_string = kwargs.get('connection_string', None) + self.use_from_location = kwargs.get('use_from_location', None) self.resource_id = kwargs.get('resource_id', None) -class CertificateConfiguration(Model): - """Certificate configuration which consist of non-trusted intermediates and - root certificates. +class CertificateCollection(msrest.serialization.Model): + """Paged Certificates list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.CertificateContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CertificateContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CertificateCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class CertificateConfiguration(msrest.serialization.Model): + """Certificate configuration which consist of non-trusted intermediates and root certificates. All required parameters must be populated in order to send to Azure. @@ -3013,11 +4103,10 @@ class CertificateConfiguration(Model): :type encoded_certificate: str :param certificate_password: Certificate Password. :type certificate_password: str - :param store_name: Required. The - System.Security.Cryptography.x509certificates.StoreName certificate store - location. Only Root and CertificateAuthority are valid locations. Possible - values include: 'CertificateAuthority', 'Root' - :type store_name: str or ~azure.mgmt.apimanagement.models.enum + :param store_name: Required. The System.Security.Cryptography.x509certificates.StoreName + certificate store location. Only Root and CertificateAuthority are valid locations. Possible + values include: "CertificateAuthority", "Root". + :type store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName :param certificate: Certificate information. :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ @@ -3033,21 +4122,21 @@ class CertificateConfiguration(Model): 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CertificateConfiguration, self).__init__(**kwargs) self.encoded_certificate = kwargs.get('encoded_certificate', None) self.certificate_password = kwargs.get('certificate_password', None) - self.store_name = kwargs.get('store_name', None) + self.store_name = kwargs['store_name'] self.certificate = kwargs.get('certificate', None) class CertificateContract(Resource): """Certificate details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3055,23 +4144,21 @@ class CertificateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param subject: Required. Subject attribute of the certificate. + :param subject: Subject attribute of the certificate. :type subject: str - :param thumbprint: Required. Thumbprint of the certificate. + :param thumbprint: Thumbprint of the certificate. :type thumbprint: str - :param expiration_date: Required. Expiration date of the certificate. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime + :param expiration_date: Expiration date of the certificate. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime + :param key_vault: KeyVault location details of the certificate. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'subject': {'required': True}, - 'thumbprint': {'required': True}, - 'expiration_date': {'required': True}, } _attribute_map = { @@ -3081,52 +4168,55 @@ class CertificateContract(Resource): 'subject': {'key': 'properties.subject', 'type': 'str'}, 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CertificateContract, self).__init__(**kwargs) self.subject = kwargs.get('subject', None) self.thumbprint = kwargs.get('thumbprint', None) self.expiration_date = kwargs.get('expiration_date', None) + self.key_vault = kwargs.get('key_vault', None) -class CertificateCreateOrUpdateParameters(Model): +class CertificateCreateOrUpdateParameters(msrest.serialization.Model): """Certificate create or update details. - All required parameters must be populated in order to send to Azure. - - :param data: Required. Base 64 encoded certificate using the - application/x-pkcs12 representation. + :param data: Base 64 encoded certificate using the application/x-pkcs12 representation. :type data: str - :param password: Required. Password for the Certificate + :param password: Password for the Certificate. :type password: str + :param key_vault: KeyVault location details of the certificate. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - _validation = { - 'data': {'required': True}, - 'password': {'required': True}, - } - _attribute_map = { 'data': {'key': 'properties.data', 'type': 'str'}, 'password': {'key': 'properties.password', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) self.data = kwargs.get('data', None) self.password = kwargs.get('password', None) + self.key_vault = kwargs.get('key_vault', None) -class CertificateInformation(Model): +class CertificateInformation(msrest.serialization.Model): """SSL certificate information. All required parameters must be populated in order to send to Azure. - :param expiry: Required. Expiration date of the certificate. The date - conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by - the ISO 8601 standard. - :type expiry: datetime + :param expiry: Required. Expiration date of the certificate. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiry: ~datetime.datetime :param thumbprint: Required. Thumbprint of the certificate. :type thumbprint: str :param subject: Required. Subject of the certificate. @@ -3145,18 +4235,20 @@ class CertificateInformation(Model): 'subject': {'key': 'subject', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(CertificateInformation, self).__init__(**kwargs) - self.expiry = kwargs.get('expiry', None) - self.thumbprint = kwargs.get('thumbprint', None) - self.subject = kwargs.get('subject', None) + self.expiry = kwargs['expiry'] + self.thumbprint = kwargs['thumbprint'] + self.subject = kwargs['subject'] -class ClientSecretContract(Model): +class ClientSecretContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param client_secret: Client or app secret used in IdentityProviders, Aad, - OpenID or OAuth. + :param client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. :type client_secret: str """ @@ -3164,46 +4256,41 @@ class ClientSecretContract(Model): 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ClientSecretContract, self).__init__(**kwargs) self.client_secret = kwargs.get('client_secret', None) -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ConnectivityStatusContract(Model): +class ConnectivityStatusContract(msrest.serialization.Model): """Details about connectivity to a resource. All required parameters must be populated in order to send to Azure. - :param name: Required. The hostname of the resource which the service - depends on. This can be the database, storage or any other azure resource - on which the service depends upon. + :param name: Required. The hostname of the resource which the service depends on. This can be + the database, storage or any other azure resource on which the service depends upon. :type name: str - :param status: Required. Resource Connectivity Status Type identifier. - Possible values include: 'initializing', 'success', 'failure' - :type status: str or - ~azure.mgmt.apimanagement.models.ConnectivityStatusType + :param status: Required. Resource Connectivity Status Type identifier. Possible values include: + "initializing", "success", "failure". + :type status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType :param error: Error details of the connectivity to the resource. :type error: str - :param last_updated: Required. The date when the resource connectivity - status was last updated. This status should be updated every 15 minutes. - If this status has not been updated, then it means that the service has - lost network connectivity to the resource, from inside the Virtual - Network.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type last_updated: datetime - :param last_status_change: Required. The date when the resource - connectivity status last Changed from success to failure or vice-versa. - The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as - specified by the ISO 8601 standard. - :type last_status_change: datetime + :param last_updated: Required. The date when the resource connectivity status was last updated. + This status should be updated every 15 minutes. If this status has not been updated, then it + means that the service has lost network connectivity to the resource, from inside the Virtual + Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. + :type last_updated: ~datetime.datetime + :param last_status_change: Required. The date when the resource connectivity status last + Changed from success to failure or vice-versa. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type last_status_change: ~datetime.datetime + :param resource_type: Required. Resource Type. + :type resource_type: str + :param is_optional: Required. Whether this is optional. + :type is_optional: bool """ _validation = { @@ -3211,6 +4298,8 @@ class ConnectivityStatusContract(Model): 'status': {'required': True}, 'last_updated': {'required': True}, 'last_status_change': {'required': True}, + 'resource_type': {'required': True}, + 'is_optional': {'required': True}, } _attribute_map = { @@ -3219,52 +4308,352 @@ class ConnectivityStatusContract(Model): 'error': {'key': 'error', 'type': 'str'}, 'last_updated': {'key': 'lastUpdated', 'type': 'iso-8601'}, 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'is_optional': {'key': 'isOptional', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ConnectivityStatusContract, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.status = kwargs.get('status', None) + self.name = kwargs['name'] + self.status = kwargs['status'] self.error = kwargs.get('error', None) - self.last_updated = kwargs.get('last_updated', None) - self.last_status_change = kwargs.get('last_status_change', None) + self.last_updated = kwargs['last_updated'] + self.last_status_change = kwargs['last_status_change'] + self.resource_type = kwargs['resource_type'] + self.is_optional = kwargs['is_optional'] -class DeployConfigurationParameters(Model): - """Deploy Tenant Configuration Contract. +class ContentItemCollection(msrest.serialization.Model): + """Paged list of content items. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param branch: Required. The name of the Git branch from which the - configuration is to be deployed to the configuration database. - :type branch: str - :param force: The value enforcing deleting subscriptions to products that - are deleted in this update. - :type force: bool + :ivar value: Collection of content items. + :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] + :ivar next_link: Next page link, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ContentItemContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentItemCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContentItemContract(Resource): + """Content type contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :param properties: Properties of the content item. + :type properties: dict[str, object] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentItemContract, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class ContentTypeCollection(msrest.serialization.Model): + """Paged list of content types. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of content types. + :vartype value: list[~azure.mgmt.apimanagement.models.ContentTypeContract] + :ivar next_link: Next page link, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ContentTypeContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentTypeCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContentTypeContract(Resource): + """Content type contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :param id_properties_id: Content type identifier. + :type id_properties_id: str + :param name_properties_name: Content type name. Must be 1 to 250 characters long. + :type name_properties_name: str + :param description: Content type description. + :type description: str + :param schema: Content type schema. + :type schema: object + :param version: Content type version. + :type version: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, + 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'schema': {'key': 'properties.schema', 'type': 'object'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentTypeContract, self).__init__(**kwargs) + self.id_properties_id = kwargs.get('id_properties_id', None) + self.name_properties_name = kwargs.get('name_properties_name', None) + self.description = kwargs.get('description', None) + self.schema = kwargs.get('schema', None) + self.version = kwargs.get('version', None) + + +class DataMasking(msrest.serialization.Model): + """DataMasking. + + :param query_params: Masking settings for Url query parameters. + :type query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :param headers: Masking settings for headers. + :type headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + """ + + _attribute_map = { + 'query_params': {'key': 'queryParams', 'type': '[DataMaskingEntity]'}, + 'headers': {'key': 'headers', 'type': '[DataMaskingEntity]'}, + } + + def __init__( + self, + **kwargs + ): + super(DataMasking, self).__init__(**kwargs) + self.query_params = kwargs.get('query_params', None) + self.headers = kwargs.get('headers', None) + + +class DataMaskingEntity(msrest.serialization.Model): + """DataMaskingEntity. + + :param value: The name of an entity to mask (e.g. a name of a header or a query parameter). + :type value: str + :param mode: Data masking mode. Possible values include: "Mask", "Hide". + :type mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DataMaskingEntity, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.mode = kwargs.get('mode', None) + + +class DeletedServiceContract(Resource): + """Deleted Api Management Service information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :ivar location: Api Management Service Master Location. + :vartype location: str + :param service_id: Fully-qualified API Management Service Resource ID. + :type service_id: str + :param scheduled_purge_date: UTC Date and Time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :type scheduled_purge_date: ~datetime.datetime + :param deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :type deletion_date: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'service_id': {'key': 'properties.serviceId', 'type': 'str'}, + 'scheduled_purge_date': {'key': 'properties.scheduledPurgeDate', 'type': 'iso-8601'}, + 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(DeletedServiceContract, self).__init__(**kwargs) + self.location = None + self.service_id = kwargs.get('service_id', None) + self.scheduled_purge_date = kwargs.get('scheduled_purge_date', None) + self.deletion_date = kwargs.get('deletion_date', None) + + +class DeletedServicesCollection(msrest.serialization.Model): + """Paged deleted Api Management Services List Representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :ivar next_link: Next page link if any. + :vartype next_link: str """ _validation = { - 'branch': {'required': True}, + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeletedServiceContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(DeletedServicesCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class DeployConfigurationParameters(msrest.serialization.Model): + """Deploy Tenant Configuration Contract. + + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. + :type branch: str + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :type force: bool + """ + _attribute_map = { 'branch': {'key': 'properties.branch', 'type': 'str'}, 'force': {'key': 'properties.force', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DeployConfigurationParameters, self).__init__(**kwargs) self.branch = kwargs.get('branch', None) self.force = kwargs.get('force', None) +class DiagnosticCollection(msrest.serialization.Model): + """Paged Diagnostic list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DiagnosticContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DiagnosticCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class DiagnosticContract(Resource): """Diagnostic details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3272,37 +4661,35 @@ class DiagnosticContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param always_log: Specifies for what type of messages sampling settings - should not apply. Possible values include: 'allErrors' + :param always_log: Specifies for what type of messages sampling settings should not apply. + Possible values include: "allErrors". :type always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog - :param logger_id: Required. Resource Id of a target logger. + :param logger_id: Resource Id of a target logger. :type logger_id: str :param sampling: Sampling settings for Diagnostic. :type sampling: ~azure.mgmt.apimanagement.models.SamplingSettings - :param frontend: Diagnostic settings for incoming/outgoing HTTP messages - to the Gateway. - :type frontend: - ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param backend: Diagnostic settings for incoming/outgoing HTTP messages to - the Backend + :param frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :type frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :param backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. :type backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :param log_client_ip: Log the ClientIP. Default is false. :type log_client_ip: bool - :param http_correlation_protocol: Sets correlation protocol to use for - Application Insights diagnostics. Possible values include: 'None', - 'Legacy', 'W3C' + :param http_correlation_protocol: Sets correlation protocol to use for Application Insights + diagnostics. Possible values include: "None", "Legacy", "W3C". :type http_correlation_protocol: str or ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol - :param verbosity: The verbosity level applied to traces emitted by trace - policies. Possible values include: 'verbose', 'information', 'error' + :param verbosity: The verbosity level applied to traces emitted by trace policies. Possible + values include: "verbose", "information", "error". :type verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity + :param operation_name_format: The format of the Operation Name for Application Insights + telemetries. Default is Name. Possible values include: "Name", "Url". + :type operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'logger_id': {'required': True}, } _attribute_map = { @@ -3317,9 +4704,13 @@ class DiagnosticContract(Resource): 'log_client_ip': {'key': 'properties.logClientIp', 'type': 'bool'}, 'http_correlation_protocol': {'key': 'properties.httpCorrelationProtocol', 'type': 'str'}, 'verbosity': {'key': 'properties.verbosity', 'type': 'str'}, + 'operation_name_format': {'key': 'properties.operationNameFormat', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(DiagnosticContract, self).__init__(**kwargs) self.always_log = kwargs.get('always_log', None) self.logger_id = kwargs.get('logger_id', None) @@ -3329,15 +4720,36 @@ def __init__(self, **kwargs): self.log_client_ip = kwargs.get('log_client_ip', None) self.http_correlation_protocol = kwargs.get('http_correlation_protocol', None) self.verbosity = kwargs.get('verbosity', None) + self.operation_name_format = kwargs.get('operation_name_format', None) + + +class EmailTemplateCollection(msrest.serialization.Model): + """Paged email template list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EmailTemplateContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(EmailTemplateCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) class EmailTemplateContract(Resource): """Email Template details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3345,17 +4757,16 @@ class EmailTemplateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param subject: Required. Subject of the Template. + :param subject: Subject of the Template. :type subject: str - :param body: Required. Email Template Body. This should be a valid - XDocument + :param body: Email Template Body. This should be a valid XDocument. :type body: str :param title: Title of the Template. :type title: str :param description: Description of the Email Template. :type description: str - :ivar is_default: Whether the template is the default template provided by - Api Management or has been edited. + :ivar is_default: Whether the template is the default template provided by Api Management or + has been edited. :vartype is_default: bool :param parameters: Email Template Parameter values. :type parameters: @@ -3366,8 +4777,8 @@ class EmailTemplateContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'subject': {'required': True, 'max_length': 1000, 'min_length': 1}, - 'body': {'required': True, 'min_length': 1}, + 'subject': {'max_length': 1000, 'min_length': 1}, + 'body': {'min_length': 1}, 'is_default': {'readonly': True}, } @@ -3383,7 +4794,10 @@ class EmailTemplateContract(Resource): 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(EmailTemplateContract, self).__init__(**kwargs) self.subject = kwargs.get('subject', None) self.body = kwargs.get('body', None) @@ -3393,7 +4807,7 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) -class EmailTemplateParametersContractProperties(Model): +class EmailTemplateParametersContractProperties(msrest.serialization.Model): """Email Template Parameter contract. :param name: Template parameter name. @@ -3416,14 +4830,17 @@ class EmailTemplateParametersContractProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(EmailTemplateParametersContractProperties, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.title = kwargs.get('title', None) self.description = kwargs.get('description', None) -class EmailTemplateUpdateParameters(Model): +class EmailTemplateUpdateParameters(msrest.serialization.Model): """Email Template update Parameters. :param subject: Subject of the Template. @@ -3432,7 +4849,7 @@ class EmailTemplateUpdateParameters(Model): :type title: str :param description: Description of the Email Template. :type description: str - :param body: Email Template Body. This should be a valid XDocument + :param body: Email Template Body. This should be a valid XDocument. :type body: str :param parameters: Email Template Parameter values. :type parameters: @@ -3452,7 +4869,10 @@ class EmailTemplateUpdateParameters(Model): 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(EmailTemplateUpdateParameters, self).__init__(**kwargs) self.subject = kwargs.get('subject', None) self.title = kwargs.get('title', None) @@ -3461,7 +4881,7 @@ def __init__(self, **kwargs): self.parameters = kwargs.get('parameters', None) -class ErrorFieldContract(Model): +class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. :param code: Property level error code. @@ -3478,23 +4898,25 @@ class ErrorFieldContract(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorFieldContract, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) self.target = kwargs.get('target', None) -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """Error Response. - :param code: Service-defined error code. This code serves as a sub-status - for the HTTP error code specified in the response. + :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. :type code: str :param message: Human-readable representation of the error. :type message: str - :param details: The list of invalid fields send in request, in case of - validation error. + :param details: The list of invalid fields send in request, in case of validation error. :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ @@ -3504,35 +4926,25 @@ class ErrorResponse(Model): 'details': {'key': 'error.details', 'type': '[ErrorFieldContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) self.details = kwargs.get('details', None) -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class ErrorResponseBody(Model): +class ErrorResponseBody(msrest.serialization.Model): """Error Body contract. - :param code: Service-defined error code. This code serves as a sub-status - for the HTTP error code specified in the response. + :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. :type code: str :param message: Human-readable representation of the error. :type message: str - :param details: The list of invalid fields send in request, in case of - validation error. + :param details: The list of invalid fields send in request, in case of validation error. :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ @@ -3542,18 +4954,50 @@ class ErrorResponseBody(Model): 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ErrorResponseBody, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) self.details = kwargs.get('details', None) +class GatewayCollection(msrest.serialization.Model): + """Paged Gateway list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GatewayContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GatewayCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class GatewayContract(Resource): """Gateway details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3562,9 +5006,8 @@ class GatewayContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param location_data: Gateway location. - :type location_data: - ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. :type description: str """ @@ -3572,7 +5015,7 @@ class GatewayContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, } _attribute_map = { @@ -3583,17 +5026,49 @@ class GatewayContract(Resource): 'description': {'key': 'properties.description', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayContract, self).__init__(**kwargs) self.location_data = kwargs.get('location_data', None) self.description = kwargs.get('description', None) +class GatewayHostnameConfigurationCollection(msrest.serialization.Model): + """Paged Gateway hostname configuration list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GatewayHostnameConfigurationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GatewayHostnameConfigurationCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class GatewayHostnameConfigurationContract(Resource): """Gateway hostname configuration details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3601,15 +5076,19 @@ class GatewayHostnameConfigurationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param hostname: Hostname value. Supports valid domain name, partial or - full wildcard + :param hostname: Hostname value. Supports valid domain name, partial or full wildcard. :type hostname: str - :param certificate_id: Identifier of Certificate entity that will be used - for TLS connection establishment + :param certificate_id: Identifier of Certificate entity that will be used for TLS connection + establishment. :type certificate_id: str - :param negotiate_client_certificate: Determines whether gateway requests - client certificate + :param negotiate_client_certificate: Determines whether gateway requests client certificate. :type negotiate_client_certificate: bool + :param tls10_enabled: Specifies if TLS 1.0 is supported. + :type tls10_enabled: bool + :param tls11_enabled: Specifies if TLS 1.1 is supported. + :type tls11_enabled: bool + :param http2_enabled: Specifies if HTTP/2.0 is supported. + :type http2_enabled: bool """ _validation = { @@ -3625,22 +5104,31 @@ class GatewayHostnameConfigurationContract(Resource): 'hostname': {'key': 'properties.hostname', 'type': 'str'}, 'certificate_id': {'key': 'properties.certificateId', 'type': 'str'}, 'negotiate_client_certificate': {'key': 'properties.negotiateClientCertificate', 'type': 'bool'}, + 'tls10_enabled': {'key': 'properties.tls10Enabled', 'type': 'bool'}, + 'tls11_enabled': {'key': 'properties.tls11Enabled', 'type': 'bool'}, + 'http2_enabled': {'key': 'properties.http2Enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayHostnameConfigurationContract, self).__init__(**kwargs) self.hostname = kwargs.get('hostname', None) self.certificate_id = kwargs.get('certificate_id', None) self.negotiate_client_certificate = kwargs.get('negotiate_client_certificate', None) + self.tls10_enabled = kwargs.get('tls10_enabled', None) + self.tls11_enabled = kwargs.get('tls11_enabled', None) + self.http2_enabled = kwargs.get('http2_enabled', None) -class GatewayKeyRegenerationRequestContract(Model): +class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): """Gateway key regeneration request contract properties. All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key being regenerated. Possible values - include: 'primary', 'secondary' + :param key_type: Required. The Key being regenerated. Possible values include: "primary", + "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ @@ -3649,15 +5137,18 @@ class GatewayKeyRegenerationRequestContract(Model): } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'keyType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) - self.key_type = kwargs.get('key_type', None) + self.key_type = kwargs['key_type'] -class GatewayKeysContract(Model): +class GatewayKeysContract(msrest.serialization.Model): """Gateway authentication keys. :param primary: Primary gateway key. @@ -3671,13 +5162,16 @@ class GatewayKeysContract(Model): 'secondary': {'key': 'secondary', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayKeysContract, self).__init__(**kwargs) self.primary = kwargs.get('primary', None) self.secondary = kwargs.get('secondary', None) -class GatewayTokenContract(Model): +class GatewayTokenContract(msrest.serialization.Model): """Gateway access token. :param value: Shared Access Authentication token value for the Gateway. @@ -3688,24 +5182,26 @@ class GatewayTokenContract(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayTokenContract, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class GatewayTokenRequestContract(Model): +class GatewayTokenRequestContract(msrest.serialization.Model): """Gateway token request contract properties. All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key to be used to generate gateway token. - Possible values include: 'primary', 'secondary'. Default value: "primary" - . + :param key_type: Required. The Key to be used to generate gateway token. Possible values + include: "primary", "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: Required. The Expiry time of the Token. Maximum token - expiry time is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime + :param expiry: Required. The Expiry time of the Token. Maximum token expiry time is set to 30 + days. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. + :type expiry: ~datetime.datetime """ _validation = { @@ -3714,17 +5210,20 @@ class GatewayTokenRequestContract(Model): } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'keyType', 'type': 'str'}, 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GatewayTokenRequestContract, self).__init__(**kwargs) - self.key_type = kwargs.get('key_type', "primary") - self.expiry = kwargs.get('expiry', None) + self.key_type = kwargs['key_type'] + self.expiry = kwargs['expiry'] -class GenerateSsoUrlResult(Model): +class GenerateSsoUrlResult(msrest.serialization.Model): """Generate SSO Url operations response details. :param value: Redirect Url containing the SSO URL value. @@ -3735,18 +5234,41 @@ class GenerateSsoUrlResult(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GenerateSsoUrlResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) +class GroupCollection(msrest.serialization.Model): + """Paged Group list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.GroupContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GroupContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GroupCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class GroupContract(Resource): """Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3754,21 +5276,19 @@ class GroupContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. Group name. + :param display_name: Group name. :type display_name: str :param description: Group description. Can contain HTML formatting tags. :type description: str - :ivar built_in: true if the group is one of the three system groups - (Administrators, Developers, or Guests); otherwise false. + :ivar built_in: true if the group is one of the three system groups (Administrators, + Developers, or Guests); otherwise false. :vartype built_in: bool - :param group_contract_type: Group type. Possible values include: 'custom', - 'system', 'external' - :type group_contract_type: str or - ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of - the group from the external identity provider, e.g. for Azure Active - Directory `aad://.onmicrosoft.com/groups/`; - otherwise the value is null. + :param type_properties_type: Group type. Possible values include: "custom", "system", + "external". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType + :param external_id: For external groups, this property contains the id of the group from the + external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ @@ -3776,8 +5296,8 @@ class GroupContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 1000, 'min_length': 0}, 'built_in': {'readonly': True}, } @@ -3788,24 +5308,26 @@ class GroupContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'built_in': {'key': 'properties.builtIn', 'type': 'bool'}, - 'group_contract_type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GroupContract, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) self.built_in = None - self.group_contract_type = kwargs.get('group_contract_type', None) + self.type_properties_type = kwargs.get('type_properties_type', None) self.external_id = kwargs.get('external_id', None) -class GroupContractProperties(Model): +class GroupContractProperties(msrest.serialization.Model): """Group contract Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -3813,22 +5335,20 @@ class GroupContractProperties(Model): :type display_name: str :param description: Group description. Can contain HTML formatting tags. :type description: str - :ivar built_in: true if the group is one of the three system groups - (Administrators, Developers, or Guests); otherwise false. + :ivar built_in: true if the group is one of the three system groups (Administrators, + Developers, or Guests); otherwise false. :vartype built_in: bool - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of - the group from the external identity provider, e.g. for Azure Active - Directory `aad://.onmicrosoft.com/groups/`; - otherwise the value is null. + :param external_id: For external groups, this property contains the id of the group from the + external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ _validation = { 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, 'built_in': {'readonly': True}, } @@ -3836,50 +5356,52 @@ class GroupContractProperties(Model): 'display_name': {'key': 'displayName', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'built_in': {'key': 'builtIn', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'GroupType'}, + 'type': {'key': 'type', 'type': 'str'}, 'external_id': {'key': 'externalId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GroupContractProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) + self.display_name = kwargs['display_name'] self.description = kwargs.get('description', None) self.built_in = None self.type = kwargs.get('type', None) self.external_id = kwargs.get('external_id', None) -class GroupCreateParameters(Model): +class GroupCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create Group operation. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. Group name. + :param display_name: Group name. :type display_name: str :param description: Group description. :type description: str - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property - contains the id of the group from the external identity provider, e.g. for - Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + :param external_id: Identifier of the external groups, this property contains the id of the + group from the external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ _validation = { - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, } _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GroupCreateParameters, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) @@ -3887,20 +5409,18 @@ def __init__(self, **kwargs): self.external_id = kwargs.get('external_id', None) -class GroupUpdateParameters(Model): +class GroupUpdateParameters(msrest.serialization.Model): """Parameters supplied to the Update Group operation. :param display_name: Group name. :type display_name: str :param description: Group description. :type description: str - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property - contains the id of the group from the external identity provider, e.g. for - Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + :param external_id: Identifier of the external groups, this property contains the id of the + group from the external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ @@ -3911,11 +5431,14 @@ class GroupUpdateParameters(Model): _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(GroupUpdateParameters, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) @@ -3923,37 +5446,36 @@ def __init__(self, **kwargs): self.external_id = kwargs.get('external_id', None) -class HostnameConfiguration(Model): +class HostnameConfiguration(msrest.serialization.Model): """Custom hostname configuration. All required parameters must be populated in order to send to Azure. - :param type: Required. Hostname type. Possible values include: 'Proxy', - 'Portal', 'Management', 'Scm', 'DeveloperPortal' + :param type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", + "Scm", "DeveloperPortal". :type type: str or ~azure.mgmt.apimanagement.models.HostnameType - :param host_name: Required. Hostname to configure on the Api Management - service. + :param host_name: Required. Hostname to configure on the Api Management service. :type host_name: str - :param key_vault_id: Url to the KeyVault Secret containing the Ssl - Certificate. If absolute Url containing version is provided, auto-update - of ssl certificate will not work. This requires Api Management service to - be configured with MSI. The secret should be of type - *application/x-pkcs12* + :param key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url + containing version is provided, auto-update of ssl certificate will not work. This requires Api + Management service to be configured with MSI. The secret should be of type + *application/x-pkcs12*. :type key_vault_id: str + :param identity_client_id: System or User Assigned Managed identity clientId as generated by + Azure AD, which has GET access to the keyVault containing the SSL certificate. + :type identity_client_id: str :param encoded_certificate: Base64 Encoded certificate. :type encoded_certificate: str :param certificate_password: Certificate Password. :type certificate_password: str - :param default_ssl_binding: Specify true to setup the certificate - associated with this Hostname as the Default SSL Certificate. If a client - does not send the SNI header, then this will be the certificate that will - be challenged. The property is useful if a service has multiple custom - hostname enabled and it needs to decide on the default ssl certificate. - The setting only applied to Proxy Hostname Type. Default value: False . + :param default_ssl_binding: Specify true to setup the certificate associated with this Hostname + as the Default SSL Certificate. If a client does not send the SNI header, then this will be the + certificate that will be challenged. The property is useful if a service has multiple custom + hostname enabled and it needs to decide on the default ssl certificate. The setting only + applied to Proxy Hostname Type. :type default_ssl_binding: bool - :param negotiate_client_certificate: Specify true to always negotiate - client certificate on the hostname. Default Value is false. Default value: - False . + :param negotiate_client_certificate: Specify true to always negotiate client certificate on the + hostname. Default Value is false. :type negotiate_client_certificate: bool :param certificate: Certificate information. :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation @@ -3968,6 +5490,7 @@ class HostnameConfiguration(Model): 'type': {'key': 'type', 'type': 'str'}, 'host_name': {'key': 'hostName', 'type': 'str'}, 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, 'encoded_certificate': {'key': 'encodedCertificate', 'type': 'str'}, 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, 'default_ssl_binding': {'key': 'defaultSslBinding', 'type': 'bool'}, @@ -3975,11 +5498,15 @@ class HostnameConfiguration(Model): 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HostnameConfiguration, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.host_name = kwargs.get('host_name', None) + self.type = kwargs['type'] + self.host_name = kwargs['host_name'] self.key_vault_id = kwargs.get('key_vault_id', None) + self.identity_client_id = kwargs.get('identity_client_id', None) self.encoded_certificate = kwargs.get('encoded_certificate', None) self.certificate_password = kwargs.get('certificate_password', None) self.default_ssl_binding = kwargs.get('default_ssl_binding', False) @@ -3987,57 +5514,59 @@ def __init__(self, **kwargs): self.certificate = kwargs.get('certificate', None) -class HttpMessageDiagnostic(Model): +class HttpMessageDiagnostic(msrest.serialization.Model): """Http message diagnostic settings. :param headers: Array of HTTP Headers to log. :type headers: list[str] :param body: Body logging settings. :type body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings + :param data_masking: Data masking settings. + :type data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ _attribute_map = { 'headers': {'key': 'headers', 'type': '[str]'}, 'body': {'key': 'body', 'type': 'BodyDiagnosticSettings'}, + 'data_masking': {'key': 'dataMasking', 'type': 'DataMasking'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(HttpMessageDiagnostic, self).__init__(**kwargs) self.headers = kwargs.get('headers', None) self.body = kwargs.get('body', None) + self.data_masking = kwargs.get('data_masking', None) -class IdentityProviderBaseParameters(Model): +class IdentityProviderBaseParameters(msrest.serialization.Model): """Identity Provider Base Parameter Properties. - :param type: Identity Provider Type identifier. Possible values include: - 'facebook', 'google', 'microsoft', 'twitter', 'aad', 'aadB2C' + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str """ _validation = { - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, @@ -4055,7 +5584,10 @@ class IdentityProviderBaseParameters(Model): 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IdentityProviderBaseParameters, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.signin_tenant = kwargs.get('signin_tenant', None) @@ -4070,10 +5602,7 @@ def __init__(self, **kwargs): class IdentityProviderContract(Resource): """Identity Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4081,41 +5610,32 @@ class IdentityProviderContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param identity_provider_contract_type: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_contract_type: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external - Identity Provider. It is App ID for Facebook login, Client ID for Google - login, App ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Client secret of the Application in external - Identity Provider, used to authenticate login request. For example, it is - App Secret for Facebook login, API Key for Google login, Public Key for - Microsoft. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type client_secret: str """ @@ -4123,12 +5643,12 @@ class IdentityProviderContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, - 'client_id': {'required': True, 'min_length': 1}, + 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -4136,7 +5656,7 @@ class IdentityProviderContract(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'identity_provider_contract_type': {'key': 'properties.type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'signin_tenant': {'key': 'properties.signinTenant', 'type': 'str'}, 'allowed_tenants': {'key': 'properties.allowedTenants', 'type': '[str]'}, 'authority': {'key': 'properties.authority', 'type': 'str'}, @@ -4148,9 +5668,12 @@ class IdentityProviderContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IdentityProviderContract, self).__init__(**kwargs) - self.identity_provider_contract_type = kwargs.get('identity_provider_contract_type', None) + self.type_properties_type = kwargs.get('type_properties_type', None) self.signin_tenant = kwargs.get('signin_tenant', None) self.allowed_tenants = kwargs.get('allowed_tenants', None) self.authority = kwargs.get('authority', None) @@ -4162,13 +5685,76 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) +class IdentityProviderContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. + + All required parameters must be populated in order to send to Azure. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Required. Client Id of the Application in the external Identity Provider. It + is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'required': True, 'min_length': 1}, + 'client_secret': {'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityProviderContractProperties, self).__init__(**kwargs) + self.client_id = kwargs['client_id'] + self.client_secret = kwargs.get('client_secret', None) + + class IdentityProviderCreateContract(Resource): """Identity Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4176,41 +5762,32 @@ class IdentityProviderCreateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param identity_provider_create_contract_type: Identity Provider Type - identifier. Possible values include: 'facebook', 'google', 'microsoft', - 'twitter', 'aad', 'aadB2C' - :type identity_provider_create_contract_type: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external - Identity Provider. It is App ID for Facebook login, Client ID for Google - login, App ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Required. Client secret of the Application in - external Identity Provider, used to authenticate login request. For - example, it is App Secret for Facebook login, API Key for Google login, - Public Key for Microsoft. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type client_secret: str """ @@ -4218,20 +5795,20 @@ class IdentityProviderCreateContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, - 'client_id': {'required': True, 'min_length': 1}, - 'client_secret': {'required': True, 'min_length': 1}, + 'client_id': {'min_length': 1}, + 'client_secret': {'min_length': 1}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'identity_provider_create_contract_type': {'key': 'properties.type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'signin_tenant': {'key': 'properties.signinTenant', 'type': 'str'}, 'allowed_tenants': {'key': 'properties.allowedTenants', 'type': '[str]'}, 'authority': {'key': 'properties.authority', 'type': 'str'}, @@ -4243,9 +5820,12 @@ class IdentityProviderCreateContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IdentityProviderCreateContract, self).__init__(**kwargs) - self.identity_provider_create_contract_type = kwargs.get('identity_provider_create_contract_type', None) + self.type_properties_type = kwargs.get('type_properties_type', None) self.signin_tenant = kwargs.get('signin_tenant', None) self.allowed_tenants = kwargs.get('allowed_tenants', None) self.authority = kwargs.get('authority', None) @@ -4257,46 +5837,128 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) -class IdentityProviderUpdateParameters(Model): - """Parameters supplied to update Identity Provider. +class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. + + All required parameters must be populated in order to send to Azure. - :param type: Identity Provider Type identifier. Possible values include: - 'facebook', 'google', 'microsoft', 'twitter', 'aad', 'aadB2C' + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Required. Client Id of the Application in the external Identity Provider. It + is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Required. Client secret of the Application in external Identity Provider, + used to authenticate login request. For example, it is App Secret for Facebook login, API Key + for Google login, Public Key for Microsoft. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'required': True, 'min_length': 1}, + 'client_secret': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityProviderCreateContractProperties, self).__init__(**kwargs) + self.client_id = kwargs['client_id'] + self.client_secret = kwargs['client_secret'] + + +class IdentityProviderList(msrest.serialization.Model): + """List of all the Identity Providers configured on the service instance. + + :param value: Identity Provider configuration values. + :type value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IdentityProviderContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityProviderList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class IdentityProviderUpdateParameters(msrest.serialization.Model): + """Parameters supplied to update Identity Provider. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity - Provider. It is App ID for Facebook login, Client ID for Google login, App - ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Client secret of the Application in external - Identity Provider, used to authenticate login request. For example, it is - App Secret for Facebook login, API Key for Google login, Public Key for - Microsoft. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. :type client_secret: str """ _validation = { - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, @@ -4318,7 +5980,10 @@ class IdentityProviderUpdateParameters(Model): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IdentityProviderUpdateParameters, self).__init__(**kwargs) self.type = kwargs.get('type', None) self.signin_tenant = kwargs.get('signin_tenant', None) @@ -4332,13 +5997,103 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) +class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): + """Parameters supplied to the Update Identity Provider operation. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'min_length': 1}, + 'client_secret': {'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IdentityProviderUpdateProperties, self).__init__(**kwargs) + self.client_id = kwargs.get('client_id', None) + self.client_secret = kwargs.get('client_secret', None) + + +class IssueAttachmentCollection(msrest.serialization.Model): + """Paged Issue Attachment list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue Attachment values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueAttachmentContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueAttachmentCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class IssueAttachmentContract(Resource): """Issue Attachment Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4346,13 +6101,12 @@ class IssueAttachmentContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param title: Required. Filename by which the binary data will be saved. + :param title: Filename by which the binary data will be saved. :type title: str - :param content_format: Required. Either 'link' if content is provided via - an HTTP link or the MIME type of the Base64-encoded binary data provided - in the 'content' property. + :param content_format: Either 'link' if content is provided via an HTTP link or the MIME type + of the Base64-encoded binary data provided in the 'content' property. :type content_format: str - :param content: Required. An HTTP link or Base64-encoded binary data. + :param content: An HTTP link or Base64-encoded binary data. :type content: str """ @@ -4360,9 +6114,6 @@ class IssueAttachmentContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True}, - 'content_format': {'required': True}, - 'content': {'required': True}, } _attribute_map = { @@ -4374,20 +6125,80 @@ class IssueAttachmentContract(Resource): 'content': {'key': 'properties.content', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IssueAttachmentContract, self).__init__(**kwargs) self.title = kwargs.get('title', None) self.content_format = kwargs.get('content_format', None) self.content = kwargs.get('content', None) +class IssueCollection(msrest.serialization.Model): + """Paged Issue list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class IssueCommentCollection(msrest.serialization.Model): + """Paged Issue Comment list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue Comment values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueCommentContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueCommentCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class IssueCommentContract(Resource): """Issue Comment Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4395,12 +6206,11 @@ class IssueCommentContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param text: Required. Comment text. + :param text: Comment text. :type text: str :param created_date: Date and time when the comment was created. - :type created_date: datetime - :param user_id: Required. A resource identifier for the user who left the - comment. + :type created_date: ~datetime.datetime + :param user_id: A resource identifier for the user who left the comment. :type user_id: str """ @@ -4408,8 +6218,6 @@ class IssueCommentContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'text': {'required': True}, - 'user_id': {'required': True}, } _attribute_map = { @@ -4421,7 +6229,10 @@ class IssueCommentContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IssueCommentContract, self).__init__(**kwargs) self.text = kwargs.get('text', None) self.created_date = kwargs.get('created_date', None) @@ -4431,10 +6242,7 @@ def __init__(self, **kwargs): class IssueContract(Resource): """Issue Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4443,19 +6251,17 @@ class IssueContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str - :param title: Required. The issue title. + :param title: The issue title. :type title: str - :param description: Required. Text describing the issue. + :param description: Text describing the issue. :type description: str - :param user_id: Required. A resource identifier for the user created the - issue. + :param user_id: A resource identifier for the user created the issue. :type user_id: str """ @@ -4463,9 +6269,6 @@ class IssueContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True}, - 'description': {'required': True}, - 'user_id': {'required': True}, } _attribute_map = { @@ -4480,7 +6283,10 @@ class IssueContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IssueContract, self).__init__(**kwargs) self.created_date = kwargs.get('created_date', None) self.state = kwargs.get('state', None) @@ -4490,16 +6296,15 @@ def __init__(self, **kwargs): self.user_id = kwargs.get('user_id', None) -class IssueContractBaseProperties(Model): +class IssueContractBaseProperties(msrest.serialization.Model): """Issue contract Base Properties. :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str """ @@ -4509,23 +6314,70 @@ class IssueContractBaseProperties(Model): 'api_id': {'key': 'apiId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IssueContractBaseProperties, self).__init__(**kwargs) self.created_date = kwargs.get('created_date', None) self.state = kwargs.get('state', None) self.api_id = kwargs.get('api_id', None) -class IssueUpdateContract(Model): +class IssueContractProperties(IssueContractBaseProperties): + """Issue contract Properties. + + All required parameters must be populated in order to send to Azure. + + :param created_date: Date and time when the issue was created. + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". + :type state: str or ~azure.mgmt.apimanagement.models.State + :param api_id: A resource identifier for the API the issue was created for. + :type api_id: str + :param title: Required. The issue title. + :type title: str + :param description: Required. Text describing the issue. + :type description: str + :param user_id: Required. A resource identifier for the user created the issue. + :type user_id: str + """ + + _validation = { + 'title': {'required': True}, + 'description': {'required': True}, + 'user_id': {'required': True}, + } + + _attribute_map = { + 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, + 'state': {'key': 'state', 'type': 'str'}, + 'api_id': {'key': 'apiId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueContractProperties, self).__init__(**kwargs) + self.title = kwargs['title'] + self.description = kwargs['description'] + self.user_id = kwargs['user_id'] + + +class IssueUpdateContract(msrest.serialization.Model): """Issue update Parameters. :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str :param title: The issue title. :type title: str @@ -4544,7 +6396,10 @@ class IssueUpdateContract(Model): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(IssueUpdateContract, self).__init__(**kwargs) self.created_date = kwargs.get('created_date', None) self.state = kwargs.get('state', None) @@ -4554,13 +6409,152 @@ def __init__(self, **kwargs): self.user_id = kwargs.get('user_id', None) +class IssueUpdateContractProperties(IssueContractBaseProperties): + """Issue contract Update Properties. + + :param created_date: Date and time when the issue was created. + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". + :type state: str or ~azure.mgmt.apimanagement.models.State + :param api_id: A resource identifier for the API the issue was created for. + :type api_id: str + :param title: The issue title. + :type title: str + :param description: Text describing the issue. + :type description: str + :param user_id: A resource identifier for the user created the issue. + :type user_id: str + """ + + _attribute_map = { + 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, + 'state': {'key': 'state', 'type': 'str'}, + 'api_id': {'key': 'apiId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueUpdateContractProperties, self).__init__(**kwargs) + self.title = kwargs.get('title', None) + self.description = kwargs.get('description', None) + self.user_id = kwargs.get('user_id', None) + + +class KeyVaultContractCreateProperties(msrest.serialization.Model): + """Create keyVault contract details. + + :param secret_identifier: Key vault secret identifier for fetching secret. + :type secret_identifier: str + :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + be used to access key vault secret. + :type identity_client_id: str + """ + + _attribute_map = { + 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyVaultContractCreateProperties, self).__init__(**kwargs) + self.secret_identifier = kwargs.get('secret_identifier', None) + self.identity_client_id = kwargs.get('identity_client_id', None) + + +class KeyVaultContractProperties(KeyVaultContractCreateProperties): + """KeyVault contract details. + + :param secret_identifier: Key vault secret identifier for fetching secret. + :type secret_identifier: str + :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + be used to access key vault secret. + :type identity_client_id: str + :param last_status: Last time sync and refresh status of secret from key vault. + :type last_status: ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + """ + + _attribute_map = { + 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, + 'last_status': {'key': 'lastStatus', 'type': 'KeyVaultLastAccessStatusContractProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyVaultContractProperties, self).__init__(**kwargs) + self.last_status = kwargs.get('last_status', None) + + +class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): + """Issue contract Update Properties. + + :param code: Last status code for sync and refresh of secret from key vault. + :type code: str + :param message: Details of the error else empty. + :type message: str + :param time_stamp_utc: Last time secret was accessed. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type time_stamp_utc: ~datetime.datetime + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time_stamp_utc': {'key': 'timeStampUtc', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyVaultLastAccessStatusContractProperties, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.time_stamp_utc = kwargs.get('time_stamp_utc', None) + + +class LoggerCollection(msrest.serialization.Model): + """Paged Logger list representation. + + :param value: Logger values. + :type value: list[~azure.mgmt.apimanagement.models.LoggerContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LoggerContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(LoggerCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + self.next_link = kwargs.get('next_link', None) + + class LoggerContract(Resource): """Logger details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4568,20 +6562,20 @@ class LoggerContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param logger_type: Required. Logger type. Possible values include: - 'azureEventHub', 'applicationInsights' + :param logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :param description: Logger description. :type description: str - :param credentials: Required. The name and SendRule connection string of - the event hub for azureEventHub logger. + :param credentials: The name and SendRule connection string of the event hub for azureEventHub + logger. Instrumentation key for applicationInsights logger. :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before - publishing. Default is assumed to be true. + :param is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. :type is_buffered: bool - :param resource_id: Azure Resource Id of a log target (either Azure Event - Hub resource or Azure Application Insights resource). + :param resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure + Application Insights resource). :type resource_id: str """ @@ -4589,9 +6583,7 @@ class LoggerContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'logger_type': {'required': True}, - 'description': {'max_length': 256}, - 'credentials': {'required': True}, + 'description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -4605,7 +6597,10 @@ class LoggerContract(Resource): 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(LoggerContract, self).__init__(**kwargs) self.logger_type = kwargs.get('logger_type', None) self.description = kwargs.get('description', None) @@ -4614,43 +6609,201 @@ def __init__(self, **kwargs): self.resource_id = kwargs.get('resource_id', None) -class LoggerUpdateContract(Model): +class LoggerUpdateContract(msrest.serialization.Model): """Logger update contract. - :param logger_type: Logger type. Possible values include: 'azureEventHub', - 'applicationInsights' + :param logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :param description: Logger description. :type description: str :param credentials: Logger credentials. :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before - publishing. Default is assumed to be true. + :param is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. :type is_buffered: bool """ _attribute_map = { - 'logger_type': {'key': 'properties.loggerType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': '{str}'}, - 'is_buffered': {'key': 'properties.isBuffered', 'type': 'bool'}, + 'logger_type': {'key': 'properties.loggerType', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': '{str}'}, + 'is_buffered': {'key': 'properties.isBuffered', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(LoggerUpdateContract, self).__init__(**kwargs) + self.logger_type = kwargs.get('logger_type', None) + self.description = kwargs.get('description', None) + self.credentials = kwargs.get('credentials', None) + self.is_buffered = kwargs.get('is_buffered', None) + + +class NamedValueCollection(msrest.serialization.Model): + """Paged NamedValue list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.NamedValueContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NamedValueContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NamedValueCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class NamedValueContract(Resource): + """NamedValue details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'properties.tags', 'type': '[str]'}, + 'secret': {'key': 'properties.secret', 'type': 'bool'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'value': {'key': 'properties.value', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(NamedValueContract, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.secret = kwargs.get('secret', None) + self.display_name = kwargs.get('display_name', None) + self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) + + +class NamedValueEntityBaseParameters(msrest.serialization.Model): + """NamedValue Entity Base Parameters set. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + """ + + _validation = { + 'tags': {'max_items': 32, 'min_items': 0}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(NamedValueEntityBaseParameters, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.secret = kwargs.get('secret', None) + + +class NamedValueContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + All required parameters must be populated in order to send to Azure. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + period, dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ + + _validation = { + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractProperties'}, } - def __init__(self, **kwargs): - super(LoggerUpdateContract, self).__init__(**kwargs) - self.logger_type = kwargs.get('logger_type', None) - self.description = kwargs.get('description', None) - self.credentials = kwargs.get('credentials', None) - self.is_buffered = kwargs.get('is_buffered', None) + def __init__( + self, + **kwargs + ): + super(NamedValueContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) -class NamedValueContract(Resource): +class NamedValueCreateContract(Resource): """NamedValue details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4658,29 +6811,30 @@ class NamedValueContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain - only letters, digits, period, dash, and underscore characters. + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It - may not be empty or consist only of whitespace. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'max_items': 32}, - 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'max_length': 4096, 'min_length': 1}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, } _attribute_map = { @@ -4691,118 +6845,150 @@ class NamedValueContract(Resource): 'secret': {'key': 'properties.secret', 'type': 'bool'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, **kwargs): - super(NamedValueContract, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(NamedValueCreateContract, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.secret = kwargs.get('secret', None) self.display_name = kwargs.get('display_name', None) self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) -class NamedValueCreateContract(Resource): - """NamedValue details. - - Variables are only populated by the server, and will be ignored when - sending a request. +class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. All required parameters must be populated in order to send to Azure. - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type for API Management resource. - :vartype type: str - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain - only letters, digits, period, dash, and underscore characters. + :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + period, dash, and underscore characters. :type display_name: str - :param value: Required. Value of the NamedValue. Can contain policy - expressions. It may not be empty or consist only of whitespace. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST - request to get the value. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'tags': {'max_items': 32}, + 'tags': {'max_items': 32, 'min_items': 0}, 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'required': True, 'max_length': 4096, 'min_length': 1}, + 'value': {'max_length': 4096, 'min_length': 0}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'properties.tags', 'type': '[str]'}, - 'secret': {'key': 'properties.secret', 'type': 'bool'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, **kwargs): - super(NamedValueCreateContract, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) - self.display_name = kwargs.get('display_name', None) + def __init__( + self, + **kwargs + ): + super(NamedValueCreateContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) -class NamedValueEntityBaseParameters(Model): - """NamedValue Entity Base Parameters set. +class NamedValueSecretContract(msrest.serialization.Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :param value: This is secret value of the NamedValue entity. + :type value: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NamedValueSecretContract, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + - :param tags: Optional tags that when provided can be used to filter the +class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { - 'tags': {'max_items': 32}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 1}, } _attribute_map = { 'tags': {'key': 'tags', 'type': '[str]'}, 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, **kwargs): - super(NamedValueEntityBaseParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.secret = kwargs.get('secret', None) + def __init__( + self, + **kwargs + ): + super(NamedValueUpdateParameterProperties, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) -class NamedValueUpdateParameters(Model): +class NamedValueUpdateParameters(msrest.serialization.Model): """NamedValue update Parameters. - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only - letters, digits, period, dash, and underscore characters. + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It - may not be empty or consist only of whitespace. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { - 'tags': {'max_items': 32}, + 'tags': {'max_items': 32, 'min_items': 0}, 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, 'value': {'max_length': 4096, 'min_length': 1}, } @@ -4812,27 +6998,31 @@ class NamedValueUpdateParameters(Model): 'secret': {'key': 'properties.secret', 'type': 'bool'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NamedValueUpdateParameters, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.secret = kwargs.get('secret', None) self.display_name = kwargs.get('display_name', None) self.value = kwargs.get('value', None) + self.key_vault = kwargs.get('key_vault', None) -class NetworkStatusContract(Model): +class NetworkStatusContract(msrest.serialization.Model): """Network Status details. All required parameters must be populated in order to send to Azure. :param dns_servers: Required. Gets the list of DNS servers IPV4 addresses. :type dns_servers: list[str] - :param connectivity_status: Required. Gets the list of Connectivity Status - to the Resources on which the service depends upon. - :type connectivity_status: - list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] + :param connectivity_status: Required. Gets the list of Connectivity Status to the Resources on + which the service depends upon. + :type connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] """ _validation = { @@ -4845,20 +7035,22 @@ class NetworkStatusContract(Model): 'connectivity_status': {'key': 'connectivityStatus', 'type': '[ConnectivityStatusContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NetworkStatusContract, self).__init__(**kwargs) - self.dns_servers = kwargs.get('dns_servers', None) - self.connectivity_status = kwargs.get('connectivity_status', None) + self.dns_servers = kwargs['dns_servers'] + self.connectivity_status = kwargs['connectivity_status'] -class NetworkStatusContractByLocation(Model): +class NetworkStatusContractByLocation(msrest.serialization.Model): """Network Status in the Location. - :param location: Location of service + :param location: Location of service. :type location: str - :param network_status: Network status in Location - :type network_status: - ~azure.mgmt.apimanagement.models.NetworkStatusContract + :param network_status: Network status in Location. + :type network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ _validation = { @@ -4870,19 +7062,42 @@ class NetworkStatusContractByLocation(Model): 'network_status': {'key': 'networkStatus', 'type': 'NetworkStatusContract'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NetworkStatusContractByLocation, self).__init__(**kwargs) self.location = kwargs.get('location', None) self.network_status = kwargs.get('network_status', None) +class NotificationCollection(msrest.serialization.Model): + """Paged Notification list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.NotificationContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NotificationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(NotificationCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class NotificationContract(Resource): """Notification details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4890,20 +7105,19 @@ class NotificationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param title: Required. Title of the Notification. + :param title: Title of the Notification. :type title: str :param description: Description of the Notification. :type description: str :param recipients: Recipient Parameter values. - :type recipients: - ~azure.mgmt.apimanagement.models.RecipientsContractProperties + :type recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True, 'max_length': 1000, 'min_length': 1}, + 'title': {'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -4915,14 +7129,17 @@ class NotificationContract(Resource): 'recipients': {'key': 'properties.recipients', 'type': 'RecipientsContractProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(NotificationContract, self).__init__(**kwargs) self.title = kwargs.get('title', None) self.description = kwargs.get('description', None) self.recipients = kwargs.get('recipients', None) -class OAuth2AuthenticationSettingsContract(Model): +class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. :param authorization_server_id: OAuth authorization server identifier. @@ -4936,13 +7153,16 @@ class OAuth2AuthenticationSettingsContract(Model): 'scope': {'key': 'scope', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OAuth2AuthenticationSettingsContract, self).__init__(**kwargs) self.authorization_server_id = kwargs.get('authorization_server_id', None) self.scope = kwargs.get('scope', None) -class OpenIdAuthenticationSettingsContract(Model): +class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. :param openid_provider_id: OAuth authorization server identifier. @@ -4957,19 +7177,42 @@ class OpenIdAuthenticationSettingsContract(Model): 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) self.openid_provider_id = kwargs.get('openid_provider_id', None) self.bearer_token_sending_methods = kwargs.get('bearer_token_sending_methods', None) +class OpenIdConnectProviderCollection(msrest.serialization.Model): + """Paged OpenIdProviders list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OpenidConnectProviderContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OpenIdConnectProviderCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class OpenidConnectProviderContract(Resource): """OpenId Connect Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4977,17 +7220,15 @@ class OpenidConnectProviderContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. User-friendly OpenID Connect Provider name. + :param display_name: User-friendly OpenID Connect Provider name. :type display_name: str :param description: User-friendly description of OpenID Connect Provider. :type description: str - :param metadata_endpoint: Required. Metadata endpoint URI. + :param metadata_endpoint: Metadata endpoint URI. :type metadata_endpoint: str - :param client_id: Required. Client ID of developer console which is the - client application. + :param client_id: Client ID of developer console which is the client application. :type client_id: str - :param client_secret: Client Secret of developer console which is the - client application. + :param client_secret: Client Secret of developer console which is the client application. :type client_secret: str """ @@ -4995,9 +7236,7 @@ class OpenidConnectProviderContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 50}, - 'metadata_endpoint': {'required': True}, - 'client_id': {'required': True}, + 'display_name': {'max_length': 50, 'min_length': 0}, } _attribute_map = { @@ -5011,7 +7250,10 @@ class OpenidConnectProviderContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OpenidConnectProviderContract, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) @@ -5020,7 +7262,7 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) -class OpenidConnectProviderUpdateContract(Model): +class OpenidConnectProviderUpdateContract(msrest.serialization.Model): """Parameters supplied to the Update OpenID Connect Provider operation. :param display_name: User-friendly OpenID Connect Provider name. @@ -5029,16 +7271,14 @@ class OpenidConnectProviderUpdateContract(Model): :type description: str :param metadata_endpoint: Metadata endpoint URI. :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client - application. + :param client_id: Client ID of developer console which is the client application. :type client_id: str - :param client_secret: Client Secret of developer console which is the - client application. + :param client_secret: Client Secret of developer console which is the client application. :type client_secret: str """ _validation = { - 'display_name': {'max_length': 50}, + 'display_name': {'max_length': 50, 'min_length': 0}, } _attribute_map = { @@ -5049,7 +7289,10 @@ class OpenidConnectProviderUpdateContract(Model): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OpenidConnectProviderUpdateContract, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.description = kwargs.get('description', None) @@ -5058,10 +7301,10 @@ def __init__(self, **kwargs): self.client_secret = kwargs.get('client_secret', None) -class Operation(Model): +class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation} + :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that describes the operation. :type display: ~azure.mgmt.apimanagement.models.OperationDisplay @@ -5078,7 +7321,10 @@ class Operation(Model): 'properties': {'key': 'properties', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -5086,13 +7332,40 @@ def __init__(self, **kwargs): self.properties = kwargs.get('properties', None) +class OperationCollection(msrest.serialization.Model): + """Paged Operation list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class OperationContract(Resource): """Api Operation details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5101,25 +7374,22 @@ class OperationContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str - :param display_name: Required. Operation Name. + :param display_name: Operation Name. :type display_name: str - :param method: Required. A Valid HTTP Operation Method. Typical Http - Methods like GET, PUT, POST but not limited by only them. + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :type method: str - :param url_template: Required. Relative URL template identifying the - target resource for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :type url_template: str """ @@ -5127,10 +7397,9 @@ class OperationContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 1000}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'method': {'required': True}, - 'url_template': {'required': True, 'max_length': 1000, 'min_length': 1}, + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'url_template': {'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -5147,7 +7416,10 @@ class OperationContract(Resource): 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationContract, self).__init__(**kwargs) self.template_parameters = kwargs.get('template_parameters', None) self.description = kwargs.get('description', None) @@ -5159,54 +7431,75 @@ def __init__(self, **kwargs): self.url_template = kwargs.get('url_template', None) -class OperationDisplay(Model): - """The object that describes the operation. +class OperationEntityBaseContract(msrest.serialization.Model): + """Api Operation Entity Base Contract details. - :param provider: Friendly name of the resource provider - :type provider: str - :param operation: Operation type: read, write, delete, listKeys/action, - etc. - :type operation: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param description: Friendly name of the operation + :param template_parameters: Collection of URL template parameters. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str + :param request: An entity containing request details. + :type request: ~azure.mgmt.apimanagement.models.RequestContract + :param responses: Array of Operation responses. + :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :param policies: Operation Policies. + :type policies: str """ + _validation = { + 'description': {'max_length': 1000, 'min_length': 0}, + } + _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, + 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, 'description': {'key': 'description', 'type': 'str'}, + 'request': {'key': 'request', 'type': 'RequestContract'}, + 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, + 'policies': {'key': 'policies', 'type': 'str'}, } - def __init__(self, **kwargs): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.operation = kwargs.get('operation', None) - self.resource = kwargs.get('resource', None) + def __init__( + self, + **kwargs + ): + super(OperationEntityBaseContract, self).__init__(**kwargs) + self.template_parameters = kwargs.get('template_parameters', None) self.description = kwargs.get('description', None) + self.request = kwargs.get('request', None) + self.responses = kwargs.get('responses', None) + self.policies = kwargs.get('policies', None) -class OperationEntityBaseContract(Model): - """Api Operation Entity Base Contract details. +class OperationContractProperties(OperationEntityBaseContract): + """Operation Contract Properties. + + All required parameters must be populated in order to send to Azure. :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str + :param display_name: Required. Operation Name. + :type display_name: str + :param method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, + POST but not limited by only them. + :type method: str + :param url_template: Required. Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :type url_template: str """ _validation = { - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'method': {'required': True}, + 'url_template': {'required': True, 'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -5215,46 +7508,99 @@ class OperationEntityBaseContract(Model): 'request': {'key': 'request', 'type': 'RequestContract'}, 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, 'policies': {'key': 'policies', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'method': {'key': 'method', 'type': 'str'}, + 'url_template': {'key': 'urlTemplate', 'type': 'str'}, } - def __init__(self, **kwargs): - super(OperationEntityBaseContract, self).__init__(**kwargs) - self.template_parameters = kwargs.get('template_parameters', None) + def __init__( + self, + **kwargs + ): + super(OperationContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + self.method = kwargs['method'] + self.url_template = kwargs['url_template'] + + +class OperationDisplay(msrest.serialization.Model): + """The object that describes the operation. + + :param provider: Friendly name of the resource provider. + :type provider: str + :param operation: Operation type: read, write, delete, listKeys/action, etc. + :type operation: str + :param resource: Resource type on which the operation is performed. + :type resource: str + :param description: Friendly name of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.operation = kwargs.get('operation', None) + self.resource = kwargs.get('resource', None) self.description = kwargs.get('description', None) - self.request = kwargs.get('request', None) - self.responses = kwargs.get('responses', None) - self.policies = kwargs.get('policies', None) -class OperationResultContract(Model): +class OperationListResult(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. + + :param value: List of operations supported by the resource provider. + :type value: list[~azure.mgmt.apimanagement.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationResultContract(msrest.serialization.Model): """Operation Result. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :param id: Operation result identifier. :type id: str - :param status: Status of an async operation. Possible values include: - 'Started', 'InProgress', 'Succeeded', 'Failed' + :param status: Status of an async operation. Possible values include: "Started", "InProgress", + "Succeeded", "Failed". :type status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :param started: Start time of an async operation. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type started: datetime - :param updated: Last update time of an async operation. The date conforms - to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO - 8601 standard. - :type updated: datetime + :param started: Start time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type started: ~datetime.datetime + :param updated: Last update time of an async operation. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type updated: ~datetime.datetime :param result_info: Optional result info. :type result_info: str - :param error: Error Body Contract + :param error: Error Body Contract. :type error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - :ivar action_log: This property if only provided as part of the - TenantConfiguration_Validate operation. It contains the log the entities - which will be updated/created/deleted as part of the - TenantConfiguration_Deploy operation. - :vartype action_log: - list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] + :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate + operation. It contains the log the entities which will be updated/created/deleted as part of + the TenantConfiguration_Deploy operation. + :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] """ _validation = { @@ -5263,7 +7609,7 @@ class OperationResultContract(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'AsyncOperationStatus'}, + 'status': {'key': 'status', 'type': 'str'}, 'started': {'key': 'started', 'type': 'iso-8601'}, 'updated': {'key': 'updated', 'type': 'iso-8601'}, 'result_info': {'key': 'resultInfo', 'type': 'str'}, @@ -5271,7 +7617,10 @@ class OperationResultContract(Model): 'action_log': {'key': 'actionLog', 'type': '[OperationResultLogItemContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationResultContract, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.status = kwargs.get('status', None) @@ -5282,7 +7631,7 @@ def __init__(self, **kwargs): self.action_log = None -class OperationResultLogItemContract(Model): +class OperationResultLogItemContract(msrest.serialization.Model): """Log of the entity being created, updated or deleted. :param object_type: The type of entity contract. @@ -5299,18 +7648,20 @@ class OperationResultLogItemContract(Model): 'object_key': {'key': 'objectKey', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationResultLogItemContract, self).__init__(**kwargs) self.object_type = kwargs.get('object_type', None) self.action = kwargs.get('action', None) self.object_key = kwargs.get('object_key', None) -class OperationTagResourceContractProperties(Model): +class OperationTagResourceContractProperties(msrest.serialization.Model): """Operation Entity contract Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :param id: Identifier of the operation in form /operations/{operationId}. :type id: str @@ -5324,12 +7675,11 @@ class OperationTagResourceContractProperties(Model): :vartype api_version: str :ivar description: Operation Description. :vartype description: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like - GET, PUT, POST but not limited by only them. + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :vartype method: str - :ivar url_template: Relative URL template identifying the target resource - for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :ivar url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :vartype url_template: str """ @@ -5354,7 +7704,10 @@ class OperationTagResourceContractProperties(Model): 'url_template': {'key': 'urlTemplate', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(OperationTagResourceContractProperties, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = None @@ -5366,62 +7719,112 @@ def __init__(self, **kwargs): self.url_template = None -class OperationUpdateContract(Model): - """Api Operation Update Contract details. +class OperationUpdateContract(msrest.serialization.Model): + """Api Operation Update Contract details. + + :param template_parameters: Collection of URL template parameters. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. + :type description: str + :param request: An entity containing request details. + :type request: ~azure.mgmt.apimanagement.models.RequestContract + :param responses: Array of Operation responses. + :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :param policies: Operation Policies. + :type policies: str + :param display_name: Operation Name. + :type display_name: str + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. + :type method: str + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :type url_template: str + """ + + _validation = { + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'url_template': {'max_length': 1000, 'min_length': 1}, + } + + _attribute_map = { + 'template_parameters': {'key': 'properties.templateParameters', 'type': '[ParameterContract]'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'request': {'key': 'properties.request', 'type': 'RequestContract'}, + 'responses': {'key': 'properties.responses', 'type': '[ResponseContract]'}, + 'policies': {'key': 'properties.policies', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'method': {'key': 'properties.method', 'type': 'str'}, + 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationUpdateContract, self).__init__(**kwargs) + self.template_parameters = kwargs.get('template_parameters', None) + self.description = kwargs.get('description', None) + self.request = kwargs.get('request', None) + self.responses = kwargs.get('responses', None) + self.policies = kwargs.get('policies', None) + self.display_name = kwargs.get('display_name', None) + self.method = kwargs.get('method', None) + self.url_template = kwargs.get('url_template', None) + + +class OperationUpdateContractProperties(OperationEntityBaseContract): + """Operation Update Contract Properties. :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str :param display_name: Operation Name. :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like - GET, PUT, POST but not limited by only them. + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :type method: str - :param url_template: Relative URL template identifying the target resource - for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :type url_template: str """ _validation = { - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'url_template': {'max_length': 1000, 'min_length': 1}, } _attribute_map = { - 'template_parameters': {'key': 'properties.templateParameters', 'type': '[ParameterContract]'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'request': {'key': 'properties.request', 'type': 'RequestContract'}, - 'responses': {'key': 'properties.responses', 'type': '[ResponseContract]'}, - 'policies': {'key': 'properties.policies', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'method': {'key': 'properties.method', 'type': 'str'}, - 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, + 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, + 'description': {'key': 'description', 'type': 'str'}, + 'request': {'key': 'request', 'type': 'RequestContract'}, + 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, + 'policies': {'key': 'policies', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'method': {'key': 'method', 'type': 'str'}, + 'url_template': {'key': 'urlTemplate', 'type': 'str'}, } - def __init__(self, **kwargs): - super(OperationUpdateContract, self).__init__(**kwargs) - self.template_parameters = kwargs.get('template_parameters', None) - self.description = kwargs.get('description', None) - self.request = kwargs.get('request', None) - self.responses = kwargs.get('responses', None) - self.policies = kwargs.get('policies', None) + def __init__( + self, + **kwargs + ): + super(OperationUpdateContractProperties, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) self.method = kwargs.get('method', None) self.url_template = kwargs.get('url_template', None) -class ParameterContract(Model): +class ParameterContract(msrest.serialization.Model): """Operation parameters details. All required parameters must be populated in order to send to Azure. @@ -5454,17 +7857,20 @@ class ParameterContract(Model): 'values': {'key': 'values', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ParameterContract, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.description = kwargs.get('description', None) - self.type = kwargs.get('type', None) + self.type = kwargs['type'] self.default_value = kwargs.get('default_value', None) self.required = kwargs.get('required', None) self.values = kwargs.get('values', None) -class PipelineDiagnosticSettings(Model): +class PipelineDiagnosticSettings(msrest.serialization.Model): """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. :param request: Diagnostic settings for request. @@ -5478,13 +7884,16 @@ class PipelineDiagnosticSettings(Model): 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PipelineDiagnosticSettings, self).__init__(**kwargs) self.request = kwargs.get('request', None) self.response = kwargs.get('response', None) -class PolicyCollection(Model): +class PolicyCollection(msrest.serialization.Model): """The response of the list policy operation. :param value: Policy Contract value. @@ -5498,7 +7907,10 @@ class PolicyCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -5507,10 +7919,7 @@ def __init__(self, **kwargs): class PolicyContract(Resource): """Policy Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5518,10 +7927,10 @@ class PolicyContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param value: Required. Contents of the Policy as defined by the format. + :param value: Contents of the Policy as defined by the format. :type value: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link'. Default value: "xml" . + :param format: Format of the policyContent. Possible values include: "xml", "xml-link", + "rawxml", "rawxml-link". Default value: "xml". :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat """ @@ -5529,7 +7938,6 @@ class PolicyContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'value': {'required': True}, } _attribute_map = { @@ -5540,18 +7948,20 @@ class PolicyContract(Resource): 'format': {'key': 'properties.format', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyContract, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.format = kwargs.get('format', "xml") -class PolicyDescriptionCollection(Model): +class PolicyDescriptionCollection(msrest.serialization.Model): """Descriptions of APIM policies. :param value: Descriptions of APIM policies. - :type value: - list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] + :type value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] :param count: Total record count number. :type count: long """ @@ -5561,7 +7971,10 @@ class PolicyDescriptionCollection(Model): 'count': {'key': 'count', 'type': 'long'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDescriptionCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.count = kwargs.get('count', None) @@ -5570,8 +7983,7 @@ def __init__(self, **kwargs): class PolicyDescriptionContract(Resource): """Policy description details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5601,7 +8013,10 @@ class PolicyDescriptionContract(Resource): 'scope': {'key': 'properties.scope', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PolicyDescriptionContract, self).__init__(**kwargs) self.description = None self.scope = None @@ -5610,8 +8025,7 @@ def __init__(self, **kwargs): class PortalDelegationSettings(Resource): """Delegation settings for a developer portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5621,12 +8035,11 @@ class PortalDelegationSettings(Resource): :vartype type: str :param url: A delegation Url. :type url: str - :param validation_key: A base64-encoded validation key to validate, that a - request is coming from Azure API Management. + :param validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. :type validation_key: str :param subscriptions: Subscriptions delegation settings. - :type subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :param user_registration: User registration delegation settings. :type user_registration: ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties @@ -5648,7 +8061,10 @@ class PortalDelegationSettings(Resource): 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PortalDelegationSettings, self).__init__(**kwargs) self.url = kwargs.get('url', None) self.validation_key = kwargs.get('validation_key', None) @@ -5656,11 +8072,10 @@ def __init__(self, **kwargs): self.user_registration = kwargs.get('user_registration', None) -class PortalSettingValidationKeyContract(Model): +class PortalSettingValidationKeyContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param validation_key: This is secret value of the validation key in - portal settings. + :param validation_key: This is secret value of the validation key in portal settings. :type validation_key: str """ @@ -5668,7 +8083,10 @@ class PortalSettingValidationKeyContract(Model): 'validation_key': {'key': 'validationKey', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PortalSettingValidationKeyContract, self).__init__(**kwargs) self.validation_key = kwargs.get('validation_key', None) @@ -5676,8 +8094,7 @@ def __init__(self, **kwargs): class PortalSigninSettings(Resource): """Sign-In settings for the Developer Portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5702,7 +8119,10 @@ class PortalSigninSettings(Resource): 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PortalSigninSettings, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', None) @@ -5710,8 +8130,7 @@ def __init__(self, **kwargs): class PortalSignupSettings(Resource): """Sign-Up settings for a developer portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5722,8 +8141,7 @@ class PortalSignupSettings(Resource): :param enabled: Allow users to sign up on a developer portal. :type enabled: bool :param terms_of_service: Terms of service contract properties. - :type terms_of_service: - ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { @@ -5740,19 +8158,42 @@ class PortalSignupSettings(Resource): 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(PortalSignupSettings, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', None) self.terms_of_service = kwargs.get('terms_of_service', None) +class ProductCollection(msrest.serialization.Model): + """Paged Products list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ProductContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ProductContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProductCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class ProductContract(Resource): """Product details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5762,36 +8203,31 @@ class ProductContract(Resource): :vartype type: str :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Required. Product name. + :param display_name: Product name. :type display_name: str """ @@ -5800,7 +8236,7 @@ class ProductContract(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'description': {'max_length': 1000, 'min_length': 1}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, } _attribute_map = { @@ -5812,11 +8248,14 @@ class ProductContract(Resource): 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'ProductState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProductContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.terms = kwargs.get('terms', None) @@ -5827,39 +8266,34 @@ def __init__(self, **kwargs): self.display_name = kwargs.get('display_name', None) -class ProductEntityBaseParameters(Model): +class ProductEntityBaseParameters(msrest.serialization.Model): """Product Entity Base Parameters. :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState """ @@ -5873,10 +8307,13 @@ class ProductEntityBaseParameters(Model): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'ProductState'}, + 'state': {'key': 'state', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProductEntityBaseParameters, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.terms = kwargs.get('terms', None) @@ -5886,6 +8323,64 @@ def __init__(self, **kwargs): self.state = kwargs.get('state', None) +class ProductContractProperties(ProductEntityBaseParameters): + """Product profile. + + All required parameters must be populated in order to send to Azure. + + :param description: Product description. May include HTML formatting tags. + :type description: str + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :type terms: str + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :type subscription_required: bool + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :type approval_required: bool + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :type subscriptions_limit: int + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". + :type state: str or ~azure.mgmt.apimanagement.models.ProductState + :param display_name: Required. Product name. + :type display_name: str + """ + + _validation = { + 'description': {'max_length': 1000, 'min_length': 1}, + 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'terms': {'key': 'terms', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, + 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, + 'state': {'key': 'state', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProductContractProperties, self).__init__(**kwargs) + self.display_name = kwargs['display_name'] + + class ProductTagResourceContractProperties(ProductEntityBaseParameters): """Product profile. @@ -5893,36 +8388,31 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param id: Identifier of the product in the form of /products/{productId} + :param id: Identifier of the product in the form of /products/{productId}. :type id: str :param name: Required. Product name. :type name: str @@ -5939,50 +8429,48 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'ProductState'}, + 'state': {'key': 'state', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProductTagResourceContractProperties, self).__init__(**kwargs) self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] -class ProductUpdateParameters(Model): +class ProductUpdateParameters(msrest.serialization.Model): """Product Update parameters. :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState :param display_name: Product name. :type display_name: str @@ -5999,11 +8487,14 @@ class ProductUpdateParameters(Model): 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'ProductState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ProductUpdateParameters, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.terms = kwargs.get('terms', None) @@ -6014,23 +8505,63 @@ def __init__(self, **kwargs): self.display_name = kwargs.get('display_name', None) -class PropertyValueContract(Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +class ProductUpdateProperties(ProductEntityBaseParameters): + """Parameters supplied to the Update Product operation. - :param value: This is secret value of the NamedValue entity. - :type value: str + :param description: Product description. May include HTML formatting tags. + :type description: str + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :type terms: str + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :type subscription_required: bool + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :type approval_required: bool + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :type subscriptions_limit: int + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". + :type state: str or ~azure.mgmt.apimanagement.models.ProductState + :param display_name: Product name. + :type display_name: str """ + _validation = { + 'description': {'max_length': 1000, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'terms': {'key': 'terms', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, + 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, + 'state': {'key': 'state', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, } - def __init__(self, **kwargs): - super(PropertyValueContract, self).__init__(**kwargs) - self.value = kwargs.get('value', None) + def __init__( + self, + **kwargs + ): + super(ProductUpdateProperties, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) -class QuotaCounterCollection(Model): +class QuotaCounterCollection(msrest.serialization.Model): """Paged Quota Counter list representation. :param value: Quota counter values. @@ -6047,35 +8578,34 @@ class QuotaCounterCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(QuotaCounterCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.count = kwargs.get('count', None) self.next_link = kwargs.get('next_link', None) -class QuotaCounterContract(Model): +class QuotaCounterContract(msrest.serialization.Model): """Quota counter details. All required parameters must be populated in order to send to Azure. - :param counter_key: Required. The Key value of the Counter. Must not be - empty. + :param counter_key: Required. The Key value of the Counter. Must not be empty. :type counter_key: str - :param period_key: Required. Identifier of the Period for which the - counter was collected. Must not be empty. + :param period_key: Required. Identifier of the Period for which the counter was collected. Must + not be empty. :type period_key: str - :param period_start_time: Required. The date of the start of Counter - Period. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type period_start_time: datetime - :param period_end_time: Required. The date of the end of Counter Period. - The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as - specified by the ISO 8601 standard. - :type period_end_time: datetime - :param value: Quota Value Properties - :type value: - ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + :param period_start_time: Required. The date of the start of Counter Period. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type period_start_time: ~datetime.datetime + :param period_end_time: Required. The date of the end of Counter Period. The date conforms to + the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type period_end_time: ~datetime.datetime + :param value: Quota Value Properties. + :type value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ _validation = { @@ -6093,16 +8623,19 @@ class QuotaCounterContract(Model): 'value': {'key': 'value', 'type': 'QuotaCounterValueContractProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(QuotaCounterContract, self).__init__(**kwargs) - self.counter_key = kwargs.get('counter_key', None) - self.period_key = kwargs.get('period_key', None) - self.period_start_time = kwargs.get('period_start_time', None) - self.period_end_time = kwargs.get('period_end_time', None) + self.counter_key = kwargs['counter_key'] + self.period_key = kwargs['period_key'] + self.period_start_time = kwargs['period_start_time'] + self.period_end_time = kwargs['period_end_time'] self.value = kwargs.get('value', None) -class QuotaCounterValueContract(Model): +class QuotaCounterValueContract(msrest.serialization.Model): """Quota counter value details. :param calls_count: Number of times Counter was called. @@ -6116,13 +8649,16 @@ class QuotaCounterValueContract(Model): 'kb_transferred': {'key': 'value.kbTransferred', 'type': 'float'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(QuotaCounterValueContract, self).__init__(**kwargs) self.calls_count = kwargs.get('calls_count', None) self.kb_transferred = kwargs.get('kb_transferred', None) -class QuotaCounterValueContractProperties(Model): +class QuotaCounterValueContractProperties(msrest.serialization.Model): """Quota counter value details. :param calls_count: Number of times Counter was called. @@ -6136,13 +8672,39 @@ class QuotaCounterValueContractProperties(Model): 'kb_transferred': {'key': 'kbTransferred', 'type': 'float'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(QuotaCounterValueContractProperties, self).__init__(**kwargs) self.calls_count = kwargs.get('calls_count', None) self.kb_transferred = kwargs.get('kb_transferred', None) -class RecipientEmailCollection(Model): +class QuotaCounterValueUpdateContract(msrest.serialization.Model): + """Quota counter value details. + + :param calls_count: Number of times Counter was called. + :type calls_count: int + :param kb_transferred: Data Transferred in KiloBytes. + :type kb_transferred: float + """ + + _attribute_map = { + 'calls_count': {'key': 'properties.callsCount', 'type': 'int'}, + 'kb_transferred': {'key': 'properties.kbTransferred', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaCounterValueUpdateContract, self).__init__(**kwargs) + self.calls_count = kwargs.get('calls_count', None) + self.kb_transferred = kwargs.get('kb_transferred', None) + + +class RecipientEmailCollection(msrest.serialization.Model): """Paged Recipient User list representation. :param value: Page values. @@ -6156,7 +8718,10 @@ class RecipientEmailCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecipientEmailCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -6165,8 +8730,7 @@ def __init__(self, **kwargs): class RecipientEmailContract(Resource): """Recipient Email details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6191,12 +8755,15 @@ class RecipientEmailContract(Resource): 'email': {'key': 'properties.email', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecipientEmailContract, self).__init__(**kwargs) self.email = kwargs.get('email', None) -class RecipientsContractProperties(Model): +class RecipientsContractProperties(msrest.serialization.Model): """Notification Parameter contract. :param emails: List of Emails subscribed for the notification. @@ -6210,13 +8777,16 @@ class RecipientsContractProperties(Model): 'users': {'key': 'users', 'type': '[str]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecipientsContractProperties, self).__init__(**kwargs) self.emails = kwargs.get('emails', None) self.users = kwargs.get('users', None) -class RecipientUserCollection(Model): +class RecipientUserCollection(msrest.serialization.Model): """Paged Recipient User list representation. :param value: Page values. @@ -6230,7 +8800,10 @@ class RecipientUserCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecipientUserCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -6239,8 +8812,7 @@ def __init__(self, **kwargs): class RecipientUserContract(Resource): """Recipient User details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6265,16 +8837,18 @@ class RecipientUserContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RecipientUserContract, self).__init__(**kwargs) self.user_id = kwargs.get('user_id', None) -class RegionContract(Model): +class RegionContract(msrest.serialization.Model): """Region profile. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Region name. :vartype name: str @@ -6294,14 +8868,44 @@ class RegionContract(Model): 'is_deleted': {'key': 'isDeleted', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RegionContract, self).__init__(**kwargs) self.name = None self.is_master_region = kwargs.get('is_master_region', None) self.is_deleted = kwargs.get('is_deleted', None) -class RegistrationDelegationSettingsProperties(Model): +class RegionListResult(msrest.serialization.Model): + """Lists Regions operation response details. + + :param value: Lists of Regions. + :type value: list[~azure.mgmt.apimanagement.models.RegionContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RegionContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(RegionListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + self.next_link = kwargs.get('next_link', None) + + +class RegistrationDelegationSettingsProperties(msrest.serialization.Model): """User registration delegation settings properties. :param enabled: Enable or disable delegation for user registration. @@ -6312,26 +8916,54 @@ class RegistrationDelegationSettingsProperties(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RegistrationDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', None) -class ReportRecordContract(Model): +class ReportCollection(msrest.serialization.Model): + """Paged Report records list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReportRecordContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReportCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + self.next_link = kwargs.get('next_link', None) + + +class ReportRecordContract(msrest.serialization.Model): """Report data. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param name: Name depending on report endpoint specifies product, API, - operation or developer name. + :param name: Name depending on report endpoint specifies product, API, operation or developer + name. :type name: str - :param timestamp: Start of aggregation period. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type timestamp: datetime - :param interval: Length of aggregation period. Interval must be multiple - of 15 minutes and may not be zero. The value should be in ISO 8601 format + :param timestamp: Start of aggregation period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type timestamp: ~datetime.datetime + :param interval: Length of aggregation period. Interval must be multiple of 15 minutes and may + not be zero. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations). :type interval: str :param country: Country to which this record data is related. @@ -6340,31 +8972,28 @@ class ReportRecordContract(Model): :type region: str :param zip: Zip code to which this record data is related. :type zip: str - :ivar user_id: User identifier path. /users/{userId} + :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str - :ivar product_id: Product identifier path. /products/{productId} + :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str - :param api_id: API identifier path. /apis/{apiId} + :param api_id: API identifier path. /apis/{apiId}. :type api_id: str - :param operation_id: Operation identifier path. - /apis/{apiId}/operations/{operationId} + :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. :type operation_id: str :param api_region: API region identifier. :type api_region: str - :param subscription_id: Subscription identifier path. - /subscriptions/{subscriptionId} + :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. :type subscription_id: str - :param call_count_success: Number of successful calls. This includes calls - returning HttpStatusCode <= 301 and HttpStatusCode.NotModified and - HttpStatusCode.TemporaryRedirect + :param call_count_success: Number of successful calls. This includes calls returning + HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. :type call_count_success: int - :param call_count_blocked: Number of calls blocked due to invalid - credentials. This includes calls returning HttpStatusCode.Unauthorized and - HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests + :param call_count_blocked: Number of calls blocked due to invalid credentials. This includes + calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and + HttpStatusCode.TooManyRequests. :type call_count_blocked: int - :param call_count_failed: Number of calls failed due to proxy or backend - errors. This includes calls returning HttpStatusCode.BadRequest(400) and - any Code between HttpStatusCode.InternalServerError (500) and 600 + :param call_count_failed: Number of calls failed due to proxy or backend errors. This includes + calls returning HttpStatusCode.BadRequest(400) and any Code between + HttpStatusCode.InternalServerError (500) and 600. :type call_count_failed: int :param call_count_other: Number of other calls. :type call_count_other: int @@ -6372,8 +9001,7 @@ class ReportRecordContract(Model): :type call_count_total: int :param bandwidth: Bandwidth consumed. :type bandwidth: long - :param cache_hit_count: Number of times when content was served from cache - policy. + :param cache_hit_count: Number of times when content was served from cache policy. :type cache_hit_count: int :param cache_miss_count: Number of times content was fetched from backend. :type cache_miss_count: int @@ -6383,14 +9011,11 @@ class ReportRecordContract(Model): :type api_time_min: float :param api_time_max: Maximum time it took to process request. :type api_time_max: float - :param service_time_avg: Average time it took to process request on - backend. + :param service_time_avg: Average time it took to process request on backend. :type service_time_avg: float - :param service_time_min: Minimum time it took to process request on - backend. + :param service_time_min: Minimum time it took to process request on backend. :type service_time_min: float - :param service_time_max: Maximum time it took to process request on - backend. + :param service_time_max: Maximum time it took to process request on backend. :type service_time_max: float """ @@ -6428,7 +9053,10 @@ class ReportRecordContract(Model): 'service_time_max': {'key': 'serviceTimeMax', 'type': 'float'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ReportRecordContract, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.timestamp = kwargs.get('timestamp', None) @@ -6458,29 +9086,25 @@ def __init__(self, **kwargs): self.service_time_max = kwargs.get('service_time_max', None) -class RepresentationContract(Model): +class RepresentationContract(msrest.serialization.Model): """Operation request/response representation details. All required parameters must be populated in order to send to Azure. - :param content_type: Required. Specifies a registered or custom content - type for this representation, e.g. application/xml. + :param content_type: Required. Specifies a registered or custom content type for this + representation, e.g. application/xml. :type content_type: str :param sample: An example of the representation. :type sample: str - :param schema_id: Schema identifier. Applicable only if 'contentType' - value is neither 'application/x-www-form-urlencoded' nor - 'multipart/form-data'. + :param schema_id: Schema identifier. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'. :type schema_id: str - :param type_name: Type name defined by the schema. Applicable only if - 'contentType' value is neither 'application/x-www-form-urlencoded' nor - 'multipart/form-data'. + :param type_name: Type name defined by the schema. Applicable only if 'contentType' value is + neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. :type type_name: str - :param form_parameters: Collection of form parameters. Required if - 'contentType' value is either 'application/x-www-form-urlencoded' or - 'multipart/form-data'.. - :type form_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] + :param form_parameters: Collection of form parameters. Required if 'contentType' value is + either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + :type form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] """ _validation = { @@ -6495,28 +9119,29 @@ class RepresentationContract(Model): 'form_parameters': {'key': 'formParameters', 'type': '[ParameterContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RepresentationContract, self).__init__(**kwargs) - self.content_type = kwargs.get('content_type', None) + self.content_type = kwargs['content_type'] self.sample = kwargs.get('sample', None) self.schema_id = kwargs.get('schema_id', None) self.type_name = kwargs.get('type_name', None) self.form_parameters = kwargs.get('form_parameters', None) -class RequestContract(Model): +class RequestContract(msrest.serialization.Model): """Operation request details. :param description: Operation request description. :type description: str :param query_parameters: Collection of operation request query parameters. - :type query_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] + :type query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :param headers: Collection of operation request headers. :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :param representations: Collection of operation request representations. - :type representations: - list[~azure.mgmt.apimanagement.models.RepresentationContract] + :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ _attribute_map = { @@ -6526,7 +9151,10 @@ class RequestContract(Model): 'representations': {'key': 'representations', 'type': '[RepresentationContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RequestContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.query_parameters = kwargs.get('query_parameters', None) @@ -6534,20 +9162,41 @@ def __init__(self, **kwargs): self.representations = kwargs.get('representations', None) -class RequestReportRecordContract(Model): +class RequestReportCollection(msrest.serialization.Model): + """Paged Report records list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :param count: Total record count number across all pages. + :type count: long + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RequestReportRecordContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + super(RequestReportCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + + +class RequestReportRecordContract(msrest.serialization.Model): """Request Report data. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param api_id: API identifier path. /apis/{apiId} + :param api_id: API identifier path. /apis/{apiId}. :type api_id: str - :param operation_id: Operation identifier path. - /apis/{apiId}/operations/{operationId} + :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. :type operation_id: str - :ivar product_id: Product identifier path. /products/{productId} + :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str - :ivar user_id: User identifier path. /users/{userId} + :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str :param method: The HTTP method associated with this request.. :type method: str @@ -6555,32 +9204,29 @@ class RequestReportRecordContract(Model): :type url: str :param ip_address: The client IP address associated with this request. :type ip_address: str - :param backend_response_code: The HTTP status code received by the gateway - as a result of forwarding this request to the backend. + :param backend_response_code: The HTTP status code received by the gateway as a result of + forwarding this request to the backend. :type backend_response_code: str :param response_code: The HTTP status code returned by the gateway. :type response_code: int :param response_size: The size of the response returned by the gateway. :type response_size: int - :param timestamp: The date and time when this request was received by the - gateway in ISO 8601 format. - :type timestamp: datetime - :param cache: Specifies if response cache was involved in generating the - response. If the value is none, the cache was not used. If the value is - hit, cached response was returned. If the value is miss, the cache was - used but lookup resulted in a miss and request was fulfilled by the - backend. + :param timestamp: The date and time when this request was received by the gateway in ISO 8601 + format. + :type timestamp: ~datetime.datetime + :param cache: Specifies if response cache was involved in generating the response. If the value + is none, the cache was not used. If the value is hit, cached response was returned. If the + value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by + the backend. :type cache: str :param api_time: The total time it took to process this request. :type api_time: float - :param service_time: he time it took to forward this request to the - backend and get the response back. + :param service_time: he time it took to forward this request to the backend and get the + response back. :type service_time: float - :param api_region: Azure region where the gateway that processed this - request is located. + :param api_region: Azure region where the gateway that processed this request is located. :type api_region: str - :param subscription_id: Subscription identifier path. - /subscriptions/{subscriptionId} + :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. :type subscription_id: str :param request_id: Request Identifier. :type request_id: str @@ -6614,7 +9260,10 @@ class RequestReportRecordContract(Model): 'request_size': {'key': 'requestSize', 'type': 'int'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(RequestReportRecordContract, self).__init__(**kwargs) self.api_id = kwargs.get('api_id', None) self.operation_id = kwargs.get('operation_id', None) @@ -6636,29 +9285,26 @@ def __init__(self, **kwargs): self.request_size = kwargs.get('request_size', None) -class ResourceLocationDataContract(Model): +class ResourceLocationDataContract(msrest.serialization.Model): """Resource location data properties. All required parameters must be populated in order to send to Azure. - :param name: Required. A canonical name for the geographic or physical - location. + :param name: Required. A canonical name for the geographic or physical location. :type name: str :param city: The city or locality where the resource is located. :type city: str - :param district: The district, state, or province where the resource is - located. + :param district: The district, state, or province where the resource is located. :type district: str - :param country_or_region: The country or region where the resource is - located. + :param country_or_region: The country or region where the resource is located. :type country_or_region: str """ _validation = { - 'name': {'required': True, 'max_length': 256}, - 'city': {'max_length': 256}, - 'district': {'max_length': 256}, - 'country_or_region': {'max_length': 256}, + 'name': {'required': True, 'max_length': 256, 'min_length': 0}, + 'city': {'max_length': 256, 'min_length': 0}, + 'district': {'max_length': 256, 'min_length': 0}, + 'country_or_region': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -6668,19 +9314,22 @@ class ResourceLocationDataContract(Model): 'country_or_region': {'key': 'countryOrRegion', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceLocationDataContract, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] self.city = kwargs.get('city', None) self.district = kwargs.get('district', None) self.country_or_region = kwargs.get('country_or_region', None) -class ResourceSku(Model): +class ResourceSku(msrest.serialization.Model): """Describes an available API Management SKU. - :param name: Name of the Sku. Possible values include: 'Developer', - 'Standard', 'Premium', 'Basic', 'Consumption' + :param name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", + "Basic", "Consumption", "Isolated". :type name: str or ~azure.mgmt.apimanagement.models.SkuType """ @@ -6688,16 +9337,18 @@ class ResourceSku(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceSku, self).__init__(**kwargs) self.name = kwargs.get('name', None) -class ResourceSkuCapacity(Model): +class ResourceSkuCapacity(msrest.serialization.Model): """Describes scaling information of a SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum capacity. :vartype minimum: int @@ -6705,10 +9356,9 @@ class ResourceSkuCapacity(Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values - include: 'automatic', 'manual', 'none' - :vartype scale_type: str or - ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType + :ivar scale_type: The scale type applicable to the sku. Possible values include: "automatic", + "manual", "none". + :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType """ _validation = { @@ -6725,7 +9375,10 @@ class ResourceSkuCapacity(Model): 'scale_type': {'key': 'scaleType', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceSkuCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -6733,11 +9386,10 @@ def __init__(self, **kwargs): self.scale_type = None -class ResourceSkuResult(Model): +class ResourceSkuResult(msrest.serialization.Model): """Describes an available API Management service SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str @@ -6759,14 +9411,46 @@ class ResourceSkuResult(Model): 'capacity': {'key': 'capacity', 'type': 'ResourceSkuCapacity'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResourceSkuResult, self).__init__(**kwargs) self.resource_type = None self.sku = None self.capacity = None -class ResponseContract(Model): +class ResourceSkuResults(msrest.serialization.Model): + """The API Management service SKUs operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. The list of skus available for the service. + :type value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] + :param next_link: The uri to fetch the next page of API Management service Skus. + :type next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceSkuResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceSkuResults, self).__init__(**kwargs) + self.value = kwargs['value'] + self.next_link = kwargs.get('next_link', None) + + +class ResponseContract(msrest.serialization.Model): """Operation response details. All required parameters must be populated in order to send to Azure. @@ -6776,8 +9460,7 @@ class ResponseContract(Model): :param description: Operation response description. :type description: str :param representations: Collection of operation response representations. - :type representations: - list[~azure.mgmt.apimanagement.models.RepresentationContract] + :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :param headers: Collection of operation response headers. :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ @@ -6793,18 +9476,21 @@ class ResponseContract(Model): 'headers': {'key': 'headers', 'type': '[ParameterContract]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(ResponseContract, self).__init__(**kwargs) - self.status_code = kwargs.get('status_code', None) + self.status_code = kwargs['status_code'] self.description = kwargs.get('description', None) self.representations = kwargs.get('representations', None) self.headers = kwargs.get('headers', None) -class SamplingSettings(Model): +class SamplingSettings(msrest.serialization.Model): """Sampling settings for Diagnostic. - :param sampling_type: Sampling type. Possible values include: 'fixed' + :param sampling_type: Sampling type. Possible values include: "fixed". :type sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType :param percentage: Rate of sampling for fixed-rate sampling. :type percentage: float @@ -6819,48 +9505,74 @@ class SamplingSettings(Model): 'percentage': {'key': 'percentage', 'type': 'float'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SamplingSettings, self).__init__(**kwargs) self.sampling_type = kwargs.get('sampling_type', None) self.percentage = kwargs.get('percentage', None) -class SaveConfigurationParameter(Model): +class SaveConfigurationParameter(msrest.serialization.Model): """Save Tenant Configuration Contract details. - All required parameters must be populated in order to send to Azure. - - :param branch: Required. The name of the Git branch in which to commit the - current configuration snapshot. + :param branch: The name of the Git branch in which to commit the current configuration + snapshot. :type branch: str - :param force: The value if true, the current configuration database is - committed to the Git repository, even if the Git repository has newer - changes that would be overwritten. + :param force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. :type force: bool """ - _validation = { - 'branch': {'required': True}, - } - _attribute_map = { 'branch': {'key': 'properties.branch', 'type': 'str'}, 'force': {'key': 'properties.force', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SaveConfigurationParameter, self).__init__(**kwargs) self.branch = kwargs.get('branch', None) self.force = kwargs.get('force', None) +class SchemaCollection(msrest.serialization.Model): + """The response of the list schema operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Api Schema Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SchemaContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SchemaCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class SchemaContract(Resource): """Schema Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6868,19 +9580,17 @@ class SchemaContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param content_type: Required. Must be a valid a media type used in a - Content-Type header as defined in the RFC 2616. Media type of the schema - document (e.g. application/json, application/xml).
- `Swagger` - Schema use `application/vnd.ms-azure-apim.swagger.definitions+json`
- - `WSDL` Schema use `application/vnd.ms-azure-apim.xsd+xml`
- - `OpenApi` Schema use `application/vnd.oai.openapi.components+json`
- - `WADL Schema` use `application/vnd.ms-azure-apim.wadl.grammars+xml`. + :param content_type: Must be a valid a media type used in a Content-Type header as defined in + the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
+ - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- + ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use + ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use + ``application/vnd.ms-azure-apim.wadl.grammars+xml``. :type content_type: str - :param value: Json escaped string defining the document representing the - Schema. Used for schemas other than Swagger/OpenAPI. + :param value: Json escaped string defining the document representing the Schema. Used for + schemas other than Swagger/OpenAPI. :type value: str - :param definitions: Types definitions. Used for Swagger/OpenAPI schemas - only, null otherwise. + :param definitions: Types definitions. Used for Swagger/OpenAPI schemas only, null otherwise. :type definitions: object """ @@ -6888,7 +9598,6 @@ class SchemaContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'content_type': {'required': True}, } _attribute_map = { @@ -6900,20 +9609,43 @@ class SchemaContract(Resource): 'definitions': {'key': 'properties.document.definitions', 'type': 'object'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SchemaContract, self).__init__(**kwargs) self.content_type = kwargs.get('content_type', None) self.value = kwargs.get('value', None) self.definitions = kwargs.get('definitions', None) +class SubscriptionCollection(msrest.serialization.Model): + """Paged Subscriptions list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SubscriptionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class SubscriptionContract(Resource): """Subscription details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6921,64 +9653,53 @@ class SubscriptionContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param owner_id: The user resource identifier of the subscription owner. - The value is a valid relative URL in the format of /users/{userId} where - {userId} is a user identifier. + :param owner_id: The user resource identifier of the subscription owner. The value is a valid + relative URL in the format of /users/{userId} where {userId} is a user identifier. :type owner_id: str - :param scope: Required. Scope like /products/{productId} or /apis or - /apis/{apiId}. + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param display_name: The name of the subscription, or null if the - subscription has no name. + :param display_name: The name of the subscription, or null if the subscription has no name. :type display_name: str - :param state: Required. Subscription state. Possible states are * active – - the subscription is active, * suspended – the subscription is blocked, and - the subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :ivar created_date: Subscription creation date. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :vartype created_date: datetime - :param start_date: Subscription activation date. The setting is for audit - purposes only and the subscription is not automatically activated. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type start_date: datetime - :param expiration_date: Subscription expiration date. The setting is for - audit purposes only and the subscription is not automatically expired. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime - :param end_date: Date when subscription was cancelled or expired. The - setting is for audit purposes only and the subscription is not - automatically cancelled. The subscription lifecycle can be managed by - using the `state` property. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type end_date: datetime - :param notification_date: Upcoming subscription expiration notification - date. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as + :ivar created_date: Subscription creation date. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_date: ~datetime.datetime + :param start_date: Subscription activation date. The setting is for audit purposes only and the + subscription is not automatically activated. The subscription lifecycle can be managed by using + the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type notification_date: datetime - :param primary_key: Subscription primary key. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :type start_date: ~datetime.datetime + :param expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: ``yyyy-MM- + ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime + :param end_date: Date when subscription was cancelled or expired. The setting is for audit + purposes only and the subscription is not automatically cancelled. The subscription lifecycle + can be managed by using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type end_date: ~datetime.datetime + :param notification_date: Upcoming subscription expiration notification date. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type notification_date: ~datetime.datetime + :param primary_key: Subscription primary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type primary_key: str - :param secondary_key: Subscription secondary key. This property will not - be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param secondary_key: Subscription secondary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type secondary_key: str - :param state_comment: Optional subscription comment added by an - administrator. + :param state_comment: Optional subscription comment added by an administrator when the state is + changed to the 'rejected'. :type state_comment: str - :param allow_tracing: Determines whether tracing is enabled + :param allow_tracing: Determines whether tracing is enabled. :type allow_tracing: bool """ @@ -6986,9 +9707,7 @@ class SubscriptionContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'scope': {'required': True}, 'display_name': {'max_length': 100, 'min_length': 0}, - 'state': {'required': True}, 'created_date': {'readonly': True}, 'primary_key': {'max_length': 256, 'min_length': 1}, 'secondary_key': {'max_length': 256, 'min_length': 1}, @@ -7001,7 +9720,7 @@ class SubscriptionContract(Resource): 'owner_id': {'key': 'properties.ownerId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, @@ -7013,7 +9732,10 @@ class SubscriptionContract(Resource): 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionContract, self).__init__(**kwargs) self.owner_id = kwargs.get('owner_id', None) self.scope = kwargs.get('scope', None) @@ -7030,43 +9752,38 @@ def __init__(self, **kwargs): self.allow_tracing = kwargs.get('allow_tracing', None) -class SubscriptionCreateParameters(Model): +class SubscriptionCreateParameters(msrest.serialization.Model): """Subscription create details. - All required parameters must be populated in order to send to Azure. - - :param owner_id: User (user id path) for whom subscription is being - created in form /users/{userId} + :param owner_id: User (user id path) for whom subscription is being created in form + /users/{userId}. :type owner_id: str - :param scope: Required. Scope like /products/{productId} or /apis or - /apis/{apiId}. + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param display_name: Required. Subscription name. + :param display_name: Subscription name. :type display_name: str - :param primary_key: Primary subscription key. If not specified during - request key will be generated automatically. + :param primary_key: Primary subscription key. If not specified during request key will be + generated automatically. :type primary_key: str - :param secondary_key: Secondary subscription key. If not specified during - request key will be generated automatically. + :param secondary_key: Secondary subscription key. If not specified during request key will be + generated automatically. :type secondary_key: str - :param state: Initial subscription state. If no value is specified, - subscription is created with Submitted state. Possible states are * active - – the subscription is active, * suspended – the subscription is blocked, - and the subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Initial subscription state. If no value is specified, subscription is created + with Submitted state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param allow_tracing: Determines whether tracing can be enabled + :param allow_tracing: Determines whether tracing can be enabled. :type allow_tracing: bool """ _validation = { - 'scope': {'required': True}, - 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'display_name': {'max_length': 100, 'min_length': 1}, 'primary_key': {'max_length': 256, 'min_length': 1}, 'secondary_key': {'max_length': 256, 'min_length': 1}, } @@ -7077,11 +9794,14 @@ class SubscriptionCreateParameters(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionCreateParameters, self).__init__(**kwargs) self.owner_id = kwargs.get('owner_id', None) self.scope = kwargs.get('scope', None) @@ -7092,7 +9812,7 @@ def __init__(self, **kwargs): self.allow_tracing = kwargs.get('allow_tracing', None) -class SubscriptionKeyParameterNamesContract(Model): +class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): """Subscription key parameter names details. :param header: Subscription key header name. @@ -7106,13 +9826,16 @@ class SubscriptionKeyParameterNamesContract(Model): 'query': {'key': 'query', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionKeyParameterNamesContract, self).__init__(**kwargs) self.header = kwargs.get('header', None) self.query = kwargs.get('query', None) -class SubscriptionKeysContract(Model): +class SubscriptionKeysContract(msrest.serialization.Model): """Subscription keys. :param primary_key: Subscription primary key. @@ -7131,13 +9854,16 @@ class SubscriptionKeysContract(Model): 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionKeysContract, self).__init__(**kwargs) self.primary_key = kwargs.get('primary_key', None) self.secondary_key = kwargs.get('secondary_key', None) -class SubscriptionsDelegationSettingsProperties(Model): +class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): """Subscriptions delegation settings properties. :param enabled: Enable or disable delegation for subscriptions. @@ -7148,44 +9874,45 @@ class SubscriptionsDelegationSettingsProperties(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionsDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', None) -class SubscriptionUpdateParameters(Model): +class SubscriptionUpdateParameters(msrest.serialization.Model): """Subscription update details. - :param owner_id: User identifier path: /users/{userId} + :param owner_id: User identifier path: /users/{userId}. :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId} + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param expiration_date: Subscription expiration date. The setting is for - audit purposes only and the subscription is not automatically expired. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime + :param expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: ``yyyy-MM- + ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime :param display_name: Subscription name. :type display_name: str :param primary_key: Primary subscription key. :type primary_key: str :param secondary_key: Secondary subscription key. :type secondary_key: str - :param state: Subscription state. Possible states are * active – the - subscription is active, * suspended – the subscription is blocked, and the - subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param state_comment: Comments describing subscription state change by the - administrator. + :param state_comment: Comments describing subscription state change by the administrator when + the state is changed to the 'rejected'. :type state_comment: str - :param allow_tracing: Determines whether tracing can be enabled + :param allow_tracing: Determines whether tracing can be enabled. :type allow_tracing: bool """ @@ -7201,12 +9928,15 @@ class SubscriptionUpdateParameters(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'state_comment': {'key': 'properties.stateComment', 'type': 'str'}, 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(SubscriptionUpdateParameters, self).__init__(**kwargs) self.owner_id = kwargs.get('owner_id', None) self.scope = kwargs.get('scope', None) @@ -7219,13 +9949,33 @@ def __init__(self, **kwargs): self.allow_tracing = kwargs.get('allow_tracing', None) +class TagCollection(msrest.serialization.Model): + """Paged Tag list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class TagContract(Resource): """Tag Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7233,7 +9983,7 @@ class TagContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. Tag name. + :param display_name: Tag name. :type display_name: str """ @@ -7241,7 +9991,7 @@ class TagContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 160, 'min_length': 1}, + 'display_name': {'max_length': 160, 'min_length': 1}, } _attribute_map = { @@ -7251,38 +10001,95 @@ class TagContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagContract, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) -class TagCreateUpdateParameters(Model): +class TagCreateUpdateParameters(msrest.serialization.Model): """Parameters supplied to Create/Update Tag operations. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. Tag name. + :param display_name: Tag name. :type display_name: str """ _validation = { - 'display_name': {'required': True, 'max_length': 160, 'min_length': 1}, + 'display_name': {'max_length': 160, 'min_length': 1}, } _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagCreateUpdateParameters, self).__init__(**kwargs) self.display_name = kwargs.get('display_name', None) +class TagDescriptionBaseProperties(msrest.serialization.Model): + """Parameters supplied to the Create TagDescription operation. + + :param description: Description of the Tag. + :type description: str + :param external_docs_url: Absolute URL of external resources describing the tag. + :type external_docs_url: str + :param external_docs_description: Description of the external resources describing the tag. + :type external_docs_description: str + """ + + _validation = { + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, + 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagDescriptionBaseProperties, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.external_docs_url = kwargs.get('external_docs_url', None) + self.external_docs_description = kwargs.get('external_docs_description', None) + + +class TagDescriptionCollection(msrest.serialization.Model): + """Paged TagDescription list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDescriptionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagDescriptionCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + class TagDescriptionContract(Resource): """Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7292,13 +10099,11 @@ class TagDescriptionContract(Resource): :vartype type: str :param description: Description of the Tag. :type description: str - :param external_docs_url: Absolute URL of external resources describing - the tag. + :param external_docs_url: Absolute URL of external resources describing the tag. :type external_docs_url: str - :param external_docs_description: Description of the external resources - describing the tag. + :param external_docs_description: Description of the external resources describing the tag. :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId} + :param tag_id: Identifier of the tag in the form of /tags/{tagId}. :type tag_id: str :param display_name: Tag name. :type display_name: str @@ -7308,7 +10113,7 @@ class TagDescriptionContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'external_docs_url': {'max_length': 2000}, + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, 'display_name': {'max_length': 160, 'min_length': 1}, } @@ -7323,7 +10128,10 @@ class TagDescriptionContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDescriptionContract, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.external_docs_url = kwargs.get('external_docs_url', None) @@ -7332,21 +10140,56 @@ def __init__(self, **kwargs): self.display_name = kwargs.get('display_name', None) -class TagDescriptionCreateParameters(Model): +class TagDescriptionContractProperties(TagDescriptionBaseProperties): + """TagDescription contract Properties. + + :param description: Description of the Tag. + :type description: str + :param external_docs_url: Absolute URL of external resources describing the tag. + :type external_docs_url: str + :param external_docs_description: Description of the external resources describing the tag. + :type external_docs_description: str + :param tag_id: Identifier of the tag in the form of /tags/{tagId}. + :type tag_id: str + :param display_name: Tag name. + :type display_name: str + """ + + _validation = { + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + 'display_name': {'max_length': 160, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, + 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, + 'tag_id': {'key': 'tagId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagDescriptionContractProperties, self).__init__(**kwargs) + self.tag_id = kwargs.get('tag_id', None) + self.display_name = kwargs.get('display_name', None) + + +class TagDescriptionCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create TagDescription operation. :param description: Description of the Tag. :type description: str - :param external_docs_url: Absolute URL of external resources describing - the tag. + :param external_docs_url: Absolute URL of external resources describing the tag. :type external_docs_url: str - :param external_docs_description: Description of the external resources - describing the tag. + :param external_docs_description: Description of the external resources describing the tag. :type external_docs_description: str """ _validation = { - 'external_docs_url': {'max_length': 2000}, + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { @@ -7355,30 +10198,52 @@ class TagDescriptionCreateParameters(Model): 'external_docs_description': {'key': 'properties.externalDocsDescription', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagDescriptionCreateParameters, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.external_docs_url = kwargs.get('external_docs_url', None) self.external_docs_description = kwargs.get('external_docs_description', None) -class TagResourceContract(Model): +class TagResourceCollection(msrest.serialization.Model): + """Paged Tag list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagResourceContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagResourceContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TagResourceCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class TagResourceContract(msrest.serialization.Model): """TagResource contract properties. All required parameters must be populated in order to send to Azure. :param tag: Required. Tag associated with the resource. - :type tag: - ~azure.mgmt.apimanagement.models.TagTagResourceContractProperties + :type tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :param api: Api associated with the tag. - :type api: - ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties + :type api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :param operation: Operation associated with the tag. - :type operation: - ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties + :type operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :param product: Product associated with the tag. - :type product: - ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties + :type product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ _validation = { @@ -7386,26 +10251,29 @@ class TagResourceContract(Model): } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'TagTagResourceContractProperties'}, + 'tag': {'key': 'tag', 'type': 'TagResourceContractProperties'}, 'api': {'key': 'api', 'type': 'ApiTagResourceContractProperties'}, 'operation': {'key': 'operation', 'type': 'OperationTagResourceContractProperties'}, 'product': {'key': 'product', 'type': 'ProductTagResourceContractProperties'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TagResourceContract, self).__init__(**kwargs) - self.tag = kwargs.get('tag', None) + self.tag = kwargs['tag'] self.api = kwargs.get('api', None) self.operation = kwargs.get('operation', None) self.product = kwargs.get('product', None) -class TagTagResourceContractProperties(Model): +class TagResourceContractProperties(msrest.serialization.Model): """Contract defining the Tag property in the Tag Resource Contract. - :param id: Tag identifier + :param id: Tag identifier. :type id: str - :param name: Tag Name + :param name: Tag Name. :type name: str """ @@ -7418,36 +10286,36 @@ class TagTagResourceContractProperties(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, **kwargs): - super(TagTagResourceContractProperties, self).__init__(**kwargs) + def __init__( + self, + **kwargs + ): + super(TagResourceContractProperties, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) -class TenantConfigurationSyncStateContract(Model): +class TenantConfigurationSyncStateContract(msrest.serialization.Model): """Tenant Configuration Synchronization State. :param branch: The name of Git branch. :type branch: str :param commit_id: The latest commit Id. :type commit_id: str - :param is_export: value indicating if last sync was save (true) or deploy - (false) operation. + :param is_export: value indicating if last sync was save (true) or deploy (false) operation. :type is_export: bool - :param is_synced: value indicating if last synchronization was later than - the configuration change. + :param is_synced: value indicating if last synchronization was later than the configuration + change. :type is_synced: bool - :param is_git_enabled: value indicating whether Git configuration access - is enabled. + :param is_git_enabled: value indicating whether Git configuration access is enabled. :type is_git_enabled: bool - :param sync_date: The date of the latest synchronization. The date - conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by - the ISO 8601 standard. - :type sync_date: datetime - :param configuration_change_date: The date of the latest configuration - change. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type configuration_change_date: datetime + :param sync_date: The date of the latest synchronization. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type sync_date: ~datetime.datetime + :param configuration_change_date: The date of the latest configuration change. The date + conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type configuration_change_date: ~datetime.datetime """ _attribute_map = { @@ -7460,7 +10328,10 @@ class TenantConfigurationSyncStateContract(Model): 'configuration_change_date': {'key': 'configurationChangeDate', 'type': 'iso-8601'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TenantConfigurationSyncStateContract, self).__init__(**kwargs) self.branch = kwargs.get('branch', None) self.commit_id = kwargs.get('commit_id', None) @@ -7471,7 +10342,7 @@ def __init__(self, **kwargs): self.configuration_change_date = kwargs.get('configuration_change_date', None) -class TermsOfServiceProperties(Model): +class TermsOfServiceProperties(msrest.serialization.Model): """Terms of service contract properties. :param text: A terms of service text. @@ -7488,14 +10359,17 @@ class TermsOfServiceProperties(Model): 'consent_required': {'key': 'consentRequired', 'type': 'bool'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TermsOfServiceProperties, self).__init__(**kwargs) self.text = kwargs.get('text', None) self.enabled = kwargs.get('enabled', None) self.consent_required = kwargs.get('consent_required', None) -class TokenBodyParameterContract(Model): +class TokenBodyParameterContract(msrest.serialization.Model): """OAuth acquire token request body parameter (www-url-form-encoded). All required parameters must be populated in order to send to Azure. @@ -7516,17 +10390,42 @@ class TokenBodyParameterContract(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(TokenBodyParameterContract, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + self.name = kwargs['name'] + self.value = kwargs['value'] + + +class UserCollection(msrest.serialization.Model): + """Paged Users list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.UserContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UserContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) class UserContract(Resource): """User details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7534,30 +10433,26 @@ class UserContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :param first_name: First name. :type first_name: str :param last_name: Last name. :type last_name: str :param email: Email address. :type email: str - :param registration_date: Date of user registration. The date conforms to - the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type registration_date: datetime + :param registration_date: Date of user registration. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. - :vartype groups: - list[~azure.mgmt.apimanagement.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { @@ -7581,7 +10476,10 @@ class UserContract(Resource): 'groups': {'key': 'properties.groups', 'type': '[GroupContractProperties]'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserContract, self).__init__(**kwargs) self.state = kwargs.get('state', "active") self.note = kwargs.get('note', None) @@ -7593,39 +10491,118 @@ def __init__(self, **kwargs): self.groups = None -class UserCreateParameters(Model): - """User create details. +class UserEntityBaseParameters(msrest.serialization.Model): + """User Entity Base Parameters set. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + """ + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + } + + def __init__( + self, + **kwargs + ): + super(UserEntityBaseParameters, self).__init__(**kwargs) + self.state = kwargs.get('state', "active") + self.note = kwargs.get('note', None) + self.identities = kwargs.get('identities', None) + + +class UserContractProperties(UserEntityBaseParameters): + """User profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param email: Email address. + :type email: str + :param registration_date: Date of user registration. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type registration_date: ~datetime.datetime + :ivar groups: Collection of groups user is part of. + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] + """ + + _validation = { + 'groups': {'readonly': True}, + } + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'registration_date': {'key': 'registrationDate', 'type': 'iso-8601'}, + 'groups': {'key': 'groups', 'type': '[GroupContractProperties]'}, + } + + def __init__( + self, + **kwargs + ): + super(UserContractProperties, self).__init__(**kwargs) + self.first_name = kwargs.get('first_name', None) + self.last_name = kwargs.get('last_name', None) + self.email = kwargs.get('email', None) + self.registration_date = kwargs.get('registration_date', None) + self.groups = None + + +class UserCreateParameterProperties(UserEntityBaseParameters): + """Parameters supplied to the Create User operation. All required parameters must be populated in order to send to Azure. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Required. Email address. Must not be empty and must be - unique within the service instance. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Required. Email address. Must not be empty and must be unique within the service + instance. :type email: str :param first_name: Required. First name. :type first_name: str :param last_name: Required. Last name. :type last_name: str - :param password: User Password. If no value is provided, a default - password is generated. + :param password: User Password. If no value is provided, a default password is generated. :type password: str - :param app_type: Determines the type of application which send the create - user request. Default is old publisher portal. Possible values include: - 'developerPortal' + :param app_type: Determines the type of application which send the create user request. Default + is legacy portal. Possible values include: "portal", "developerPortal". :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will - be sent to the newly created user. Possible values include: 'signup', - 'invite' + :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + created user. Possible values include: "signup", "invite". :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ @@ -7635,6 +10612,65 @@ class UserCreateParameters(Model): 'last_name': {'required': True, 'max_length': 100, 'min_length': 1}, } + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'email': {'key': 'email', 'type': 'str'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + 'app_type': {'key': 'appType', 'type': 'str'}, + 'confirmation': {'key': 'confirmation', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserCreateParameterProperties, self).__init__(**kwargs) + self.email = kwargs['email'] + self.first_name = kwargs['first_name'] + self.last_name = kwargs['last_name'] + self.password = kwargs.get('password', None) + self.app_type = kwargs.get('app_type', None) + self.confirmation = kwargs.get('confirmation', None) + + +class UserCreateParameters(msrest.serialization.Model): + """User create details. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. + :type email: str + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param password: User Password. If no value is provided, a default password is generated. + :type password: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy portal. Possible values include: "portal", "developerPortal". + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + created user. Possible values include: "signup", "invite". + :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation + """ + + _validation = { + 'email': {'max_length': 254, 'min_length': 1}, + 'first_name': {'max_length': 100, 'min_length': 1}, + 'last_name': {'max_length': 100, 'min_length': 1}, + } + _attribute_map = { 'state': {'key': 'properties.state', 'type': 'str'}, 'note': {'key': 'properties.note', 'type': 'str'}, @@ -7647,7 +10683,10 @@ class UserCreateParameters(Model): 'confirmation': {'key': 'properties.confirmation', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserCreateParameters, self).__init__(**kwargs) self.state = kwargs.get('state', "active") self.note = kwargs.get('note', None) @@ -7660,36 +10699,34 @@ def __init__(self, **kwargs): self.confirmation = kwargs.get('confirmation', None) -class UserEntityBaseParameters(Model): - """User Entity Base Parameters set. +class UserIdentityCollection(msrest.serialization.Model): + """List of Users Identity list representation. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param value: User Identity values. + :type value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str """ _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'value': {'key': 'value', 'type': '[UserIdentityContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, **kwargs): - super(UserEntityBaseParameters, self).__init__(**kwargs) - self.state = kwargs.get('state', "active") - self.note = kwargs.get('note', None) - self.identities = kwargs.get('identities', None) + def __init__( + self, + **kwargs + ): + super(UserIdentityCollection, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.count = kwargs.get('count', None) + self.next_link = kwargs.get('next_link', None) -class UserIdentityContract(Model): +class UserIdentityContract(msrest.serialization.Model): """User identity details. :param provider: Identity provider name. @@ -7703,13 +10740,16 @@ class UserIdentityContract(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserIdentityContract, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.id = kwargs.get('id', None) -class UserIdentityProperties(Model): +class UserIdentityProperties(msrest.serialization.Model): """UserIdentityProperties. :param principal_id: The principal id of user assigned identity. @@ -7723,44 +10763,42 @@ class UserIdentityProperties(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserIdentityProperties, self).__init__(**kwargs) self.principal_id = kwargs.get('principal_id', None) self.client_id = kwargs.get('client_id', None) -class UserTokenParameters(Model): +class UserTokenParameters(msrest.serialization.Model): """Get User Token parameters. - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The Key to be used to generate token for user. - Possible values include: 'primary', 'secondary'. Default value: "primary" - . + :param key_type: The Key to be used to generate token for user. Possible values include: + "primary", "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: Required. The Expiry time of the Token. Maximum token - expiry time is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime """ - _validation = { - 'key_type': {'required': True}, - 'expiry': {'required': True}, - } - _attribute_map = { - 'key_type': {'key': 'properties.keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'properties.keyType', 'type': 'str'}, 'expiry': {'key': 'properties.expiry', 'type': 'iso-8601'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserTokenParameters, self).__init__(**kwargs) - self.key_type = kwargs.get('key_type', "primary") + self.key_type = kwargs.get('key_type', None) self.expiry = kwargs.get('expiry', None) -class UserTokenResult(Model): +class UserTokenResult(msrest.serialization.Model): """Get User Token response details. :param value: Shared Access Authorization token for the User. @@ -7771,27 +10809,27 @@ class UserTokenResult(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserTokenResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) -class UserUpdateParameters(Model): +class UserUpdateParameters(msrest.serialization.Model): """User update parameters. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within - the service instance. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. :type email: str :param password: User Password. :type password: str @@ -7817,7 +10855,10 @@ class UserUpdateParameters(Model): 'last_name': {'key': 'properties.lastName', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(UserUpdateParameters, self).__init__(**kwargs) self.state = kwargs.get('state', "active") self.note = kwargs.get('note', None) @@ -7828,20 +10869,66 @@ def __init__(self, **kwargs): self.last_name = kwargs.get('last_name', None) -class VirtualNetworkConfiguration(Model): - """Configuration of a virtual network to which API Management service is - deployed. +class UserUpdateParametersProperties(UserEntityBaseParameters): + """Parameters supplied to the Update User operation. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. + :type email: str + :param password: User Password. + :type password: str + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + """ + + _validation = { + 'email': {'max_length': 254, 'min_length': 1}, + 'first_name': {'max_length': 100, 'min_length': 1}, + 'last_name': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'email': {'key': 'email', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(UserUpdateParametersProperties, self).__init__(**kwargs) + self.email = kwargs.get('email', None) + self.password = kwargs.get('password', None) + self.first_name = kwargs.get('first_name', None) + self.last_name = kwargs.get('last_name', None) + + +class VirtualNetworkConfiguration(msrest.serialization.Model): + """Configuration of a virtual network to which API Management service is deployed. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a - null GUID by default. + :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a null GUID by default. :vartype vnetid: str :ivar subnetname: The name of the subnet. :vartype subnetname: str - :param subnet_resource_id: The full resource ID of a subnet in a virtual - network to deploy the API Management service in. + :param subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the + API Management service in. :type subnet_resource_id: str """ @@ -7857,20 +10944,22 @@ class VirtualNetworkConfiguration(Model): 'subnet_resource_id': {'key': 'subnetResourceId', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(VirtualNetworkConfiguration, self).__init__(**kwargs) self.vnetid = None self.subnetname = None self.subnet_resource_id = kwargs.get('subnet_resource_id', None) -class X509CertificateName(Model): +class X509CertificateName(msrest.serialization.Model): """Properties of server X509Names. :param name: Common Name of the Certificate. :type name: str - :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the - Certificate. + :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. :type issuer_certificate_thumbprint: str """ @@ -7879,7 +10968,10 @@ class X509CertificateName(Model): 'issuer_certificate_thumbprint': {'key': 'issuerCertificateThumbprint', 'type': 'str'}, } - def __init__(self, **kwargs): + def __init__( + self, + **kwargs + ): super(X509CertificateName, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.issuer_certificate_thumbprint = kwargs.get('issuer_certificate_thumbprint', None) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py index 1e014d4da659..11962a5e2e16 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_models_py3.py @@ -1,29 +1,30 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model -from msrest.exceptions import HttpOperationError +import datetime +from typing import Dict, List, Optional, Union +from azure.core.exceptions import HttpResponseError +import msrest.serialization -class AccessInformationContract(Model): +from ._api_management_client_enums import * + + +class AccessInformationContract(msrest.serialization.Model): """Tenant access information contract of the API Management service. :param id: Identifier. :type id: str - :param primary_key: Primary access key. This property will not be filled - on 'GET' operations! Use '/listSecrets' POST request to get the value. + :param primary_key: Primary access key. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type primary_key: str - :param secondary_key: Secondary access key. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param secondary_key: Secondary access key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type secondary_key: str :param enabled: Determines whether direct access is enabled. :type enabled: bool @@ -36,7 +37,15 @@ class AccessInformationContract(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, *, id: str=None, primary_key: str=None, secondary_key: str=None, enabled: bool=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs + ): super(AccessInformationContract, self).__init__(**kwargs) self.id = id self.primary_key = primary_key @@ -44,7 +53,7 @@ def __init__(self, *, id: str=None, primary_key: str=None, secondary_key: str=No self.enabled = enabled -class AccessInformationUpdateParameters(Model): +class AccessInformationUpdateParameters(msrest.serialization.Model): """Tenant access information update parameters. :param enabled: Determines whether direct access is enabled. @@ -55,44 +64,45 @@ class AccessInformationUpdateParameters(Model): 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } - def __init__(self, *, enabled: bool=None, **kwargs) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): super(AccessInformationUpdateParameters, self).__init__(**kwargs) self.enabled = enabled -class AdditionalLocation(Model): +class AdditionalLocation(msrest.serialization.Model): """Description of an additional API Management resource location. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param location: Required. The location name of the additional region - among Azure Data center regions. + :param location: Required. The location name of the additional region among Azure Data center + regions. :type location: str :param sku: Required. SKU properties of the API Management service. - :type sku: - ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the - API Management service in the additional location. Available only for - Basic, Standard and Premium SKU. + :type sku: ~azure.mgmt.apimanagement.models.ApiManagementServiceSkuProperties + :param zones: A list of availability zones denoting where the resource needs to come from. + :type zones: list[str] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in the additional location. Available only for Basic, Standard, Premium and Isolated + SKU. :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of - the API Management service which is deployed in an Internal Virtual - Network in a particular additional location. Available only for Basic, - Standard and Premium SKU. + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service which is deployed in an Internal Virtual Network in a particular additional location. + Available only for Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration for - the location. + :param virtual_network_configuration: Virtual network configuration for the location. :type virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :ivar gateway_regional_url: Gateway URL of the API Management service in - the Region. + :ivar gateway_regional_url: Gateway URL of the API Management service in the Region. :vartype gateway_regional_url: str - :param disable_gateway: Property only valid for an Api Management service - deployed in multiple locations. This can be used to disable the gateway in - this additional location. Default value: False . + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in this additional location. :type disable_gateway: bool """ @@ -107,6 +117,7 @@ class AdditionalLocation(Model): _attribute_map = { 'location': {'key': 'location', 'type': 'str'}, 'sku': {'key': 'sku', 'type': 'ApiManagementServiceSkuProperties'}, + 'zones': {'key': 'zones', 'type': '[str]'}, 'public_ip_addresses': {'key': 'publicIPAddresses', 'type': '[str]'}, 'private_ip_addresses': {'key': 'privateIPAddresses', 'type': '[str]'}, 'virtual_network_configuration': {'key': 'virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, @@ -114,10 +125,20 @@ class AdditionalLocation(Model): 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, } - def __init__(self, *, location: str, sku, virtual_network_configuration=None, disable_gateway: bool=False, **kwargs) -> None: + def __init__( + self, + *, + location: str, + sku: "ApiManagementServiceSkuProperties", + zones: Optional[List[str]] = None, + virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, + disable_gateway: Optional[bool] = False, + **kwargs + ): super(AdditionalLocation, self).__init__(**kwargs) self.location = location self.sku = sku + self.zones = zones self.public_ip_addresses = None self.private_ip_addresses = None self.virtual_network_configuration = virtual_network_configuration @@ -125,11 +146,40 @@ def __init__(self, *, location: str, sku, virtual_network_configuration=None, di self.disable_gateway = disable_gateway -class Resource(Model): +class ApiCollection(msrest.serialization.Model): + """Paged Api list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class Resource(msrest.serialization.Model): """The Resource definition. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -151,7 +201,10 @@ class Resource(Model): 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -161,10 +214,7 @@ def __init__(self, **kwargs) -> None: class ApiContract(Resource): """Api details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -172,24 +222,19 @@ class ApiContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -199,30 +244,26 @@ class ApiContract(Resource): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { @@ -230,13 +271,13 @@ class ApiContract(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + 'path': {'max_length': 400, 'min_length': 0}, } _attribute_map = { @@ -259,11 +300,32 @@ class ApiContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, 'api_version_set': {'key': 'properties.apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, *, path: str, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, source_api_id: str=None, display_name: str=None, service_url: str=None, protocols=None, api_version_set=None, **kwargs) -> None: + 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, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + 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, + **kwargs + ): super(ApiContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -285,30 +347,24 @@ def __init__(self, *, path: str, description: str=None, authentication_settings= self.api_version_set = api_version_set -class ApiEntityBaseContract(Model): +class ApiEntityBaseContract(msrest.serialization.Model): """API base contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -318,20 +374,19 @@ class ApiEntityBaseContract(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -349,7 +404,22 @@ class ApiEntityBaseContract(Model): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, } - def __init__(self, *, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, **kwargs) -> None: + 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, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + **kwargs + ): super(ApiEntityBaseContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -368,29 +438,23 @@ def __init__(self, *, description: str=None, authentication_settings=None, subsc class ApiContractProperties(ApiEntityBaseContract): """Api Entity Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -400,38 +464,34 @@ class ApiContractProperties(ApiEntityBaseContract): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + within the API Management service instance. It is appended to the API endpoint base URL + specified during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, 'path': {'required': True, 'max_length': 400, 'min_length': 0}, @@ -454,11 +514,32 @@ class ApiContractProperties(ApiEntityBaseContract): 'display_name': {'key': 'displayName', 'type': 'str'}, 'service_url': {'key': 'serviceUrl', 'type': 'str'}, 'path': {'key': 'path', 'type': 'str'}, - 'protocols': {'key': 'protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, *, path: str, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, source_api_id: str=None, display_name: str=None, service_url: str=None, protocols=None, api_version_set=None, **kwargs) -> None: + def __init__( + self, + *, + path: str, + description: Optional[str] = None, + authentication_settings: Optional["AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + 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, + **kwargs + ): super(ApiContractProperties, self).__init__(description=description, authentication_settings=authentication_settings, subscription_key_parameter_names=subscription_key_parameter_names, api_type=api_type, api_revision=api_revision, api_version=api_version, is_current=is_current, api_revision_description=api_revision_description, api_version_description=api_version_description, api_version_set_id=api_version_set_id, subscription_required=subscription_required, **kwargs) self.source_api_id = source_api_id self.display_name = display_name @@ -468,32 +549,125 @@ def __init__(self, *, path: str, description: str=None, authentication_settings= self.api_version_set = api_version_set -class ApiCreateOrUpdateParameter(Model): - """API Create or Update Parameters. +class ApiContractUpdateProperties(ApiEntityBaseContract): + """API update contract properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. + + :param description: Description of the API. May include HTML formatting tags. + :type description: str + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. + :type subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :param api_type: Type of API. Possible values include: "http", "soap". + :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. + :type api_revision: str + :param api_version: Indicates the Version identifier of the API if the API is versioned. + :type api_version: str + :param is_current: Indicates if API revision is current api revision. + :type is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :param api_revision_description: Description of the Api Revision. + :type api_revision_description: str + :param api_version_description: Description of the Api Version. + :type api_version_description: str + :param api_version_set_id: A resource identifier for the related ApiVersionSet. + :type api_version_set_id: str + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :type subscription_required: bool + :param display_name: API name. + :type display_name: str + :param service_url: Absolute URL of the backend service implementing this API. + :type service_url: str + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. + :type path: str + :param protocols: Describes on which protocols the operations in this API can be invoked. + :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + """ + + _validation = { + 'api_revision': {'max_length': 100, 'min_length': 1}, + 'api_version': {'max_length': 100, 'min_length': 0}, + 'is_online': {'readonly': True}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'service_url': {'max_length': 2000, 'min_length': 1}, + 'path': {'max_length': 400, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authentication_settings': {'key': 'authenticationSettings', 'type': 'AuthenticationSettingsContract'}, + 'subscription_key_parameter_names': {'key': 'subscriptionKeyParameterNames', 'type': 'SubscriptionKeyParameterNamesContract'}, + 'api_type': {'key': 'type', 'type': 'str'}, + 'api_revision': {'key': 'apiRevision', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + 'is_current': {'key': 'isCurrent', 'type': 'bool'}, + 'is_online': {'key': 'isOnline', 'type': 'bool'}, + 'api_revision_description': {'key': 'apiRevisionDescription', 'type': 'str'}, + 'api_version_description': {'key': 'apiVersionDescription', 'type': 'str'}, + 'api_version_set_id': {'key': 'apiVersionSetId', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'service_url': {'key': 'serviceUrl', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + display_name: Optional[str] = None, + service_url: Optional[str] = None, + path: Optional[str] = None, + protocols: Optional[List[Union[str, "Protocol"]]] = None, + **kwargs + ): + super(ApiContractUpdateProperties, self).__init__(description=description, authentication_settings=authentication_settings, subscription_key_parameter_names=subscription_key_parameter_names, api_type=api_type, api_revision=api_revision, api_version=api_version, is_current=is_current, api_revision_description=api_revision_description, api_version_description=api_version_description, api_version_set_id=api_version_set_id, subscription_required=subscription_required, **kwargs) + self.display_name = display_name + self.service_url = service_url + self.path = path + self.protocols = protocols - All required parameters must be populated in order to send to Azure. - :param description: Description of the API. May include HTML formatting - tags. +class ApiCreateOrUpdateParameter(msrest.serialization.Model): + """API Create or Update Parameters. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -503,57 +677,51 @@ class ApiCreateOrUpdateParameter(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param source_api_id: API identifier of the source API. :type source_api_id: str :param display_name: API name. Must be 1 to 300 characters long. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. Cannot be more than 2000 characters long. + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. :type service_url: str - :param path: Required. Relative URL uniquely identifying this API and all - of its resource paths within the API Management service instance. It is - appended to the API endpoint base URL specified during the service - instance creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails :param value: Content value when Importing an API. :type value: str - :param format: Format of the Content in which the API is getting imported. - Possible values include: 'wadl-xml', 'wadl-link-json', 'swagger-json', - 'swagger-link-json', 'wsdl', 'wsdl-link', 'openapi', 'openapi+json', - 'openapi-link', 'openapi+json-link' + :param format: Format of the Content in which the API is getting imported. Possible values + include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl- + link", "openapi", "openapi+json", "openapi-link", "openapi+json-link". :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat - :param wsdl_selector: Criteria to limit import of WSDL to a subset of the - document. - :type wsdl_selector: - ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector :param soap_api_type: Type of Api to create. - * `http` creates a SOAP to REST API - * `soap` creates a SOAP pass-through API. Possible values include: - 'SoapToRest', 'SoapPassThrough' + + + * ``http`` creates a SOAP to REST API + * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 0}, - 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + 'path': {'max_length': 400, 'min_length': 0}, } _attribute_map = { @@ -573,7 +741,7 @@ class ApiCreateOrUpdateParameter(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, 'api_version_set': {'key': 'properties.apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, 'value': {'key': 'properties.value', 'type': 'str'}, 'format': {'key': 'properties.format', 'type': 'str'}, @@ -581,7 +749,32 @@ class ApiCreateOrUpdateParameter(Model): 'soap_api_type': {'key': 'properties.apiType', 'type': 'str'}, } - def __init__(self, *, path: str, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, source_api_id: str=None, display_name: str=None, service_url: str=None, protocols=None, api_version_set=None, value: str=None, format=None, wsdl_selector=None, soap_api_type=None, **kwargs) -> None: + 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, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + 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, + value: Optional[str] = None, + format: Optional[Union[str, "ContentFormat"]] = None, + wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + **kwargs + ): super(ApiCreateOrUpdateParameter, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -607,12 +800,146 @@ def __init__(self, *, path: str, description: str=None, authentication_settings= self.soap_api_type = soap_api_type -class ApiCreateOrUpdatePropertiesWsdlSelector(Model): +class ApiCreateOrUpdateProperties(ApiContractProperties): + """Api Create or Update Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of the API. May include HTML formatting tags. + :type description: str + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. + :type subscription_key_parameter_names: + ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract + :param api_type: Type of API. Possible values include: "http", "soap". + :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. + :type api_revision: str + :param api_version: Indicates the Version identifier of the API if the API is versioned. + :type api_version: str + :param is_current: Indicates if API revision is current api revision. + :type is_current: bool + :ivar is_online: Indicates if API revision is accessible via the gateway. + :vartype is_online: bool + :param api_revision_description: Description of the Api Revision. + :type api_revision_description: str + :param api_version_description: Description of the Api Version. + :type api_version_description: str + :param api_version_set_id: A resource identifier for the related ApiVersionSet. + :type api_version_set_id: str + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. + :type subscription_required: bool + :param source_api_id: API identifier of the source API. + :type source_api_id: str + :param display_name: API name. Must be 1 to 300 characters long. + :type display_name: str + :param service_url: Absolute URL of the backend service implementing this API. Cannot be more + than 2000 characters long. + :type service_url: str + :param path: Required. Relative URL uniquely identifying this API and all of its resource paths + within the API Management service instance. It is appended to the API endpoint base URL + specified during the service instance creation to form a public URL for this API. + :type path: str + :param protocols: Describes on which protocols the operations in this API can be invoked. + :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param value: Content value when Importing an API. + :type value: str + :param format: Format of the Content in which the API is getting imported. Possible values + include: "wadl-xml", "wadl-link-json", "swagger-json", "swagger-link-json", "wsdl", "wsdl- + link", "openapi", "openapi+json", "openapi-link", "openapi+json-link". + :type format: str or ~azure.mgmt.apimanagement.models.ContentFormat + :param wsdl_selector: Criteria to limit import of WSDL to a subset of the document. + :type wsdl_selector: ~azure.mgmt.apimanagement.models.ApiCreateOrUpdatePropertiesWsdlSelector + :param soap_api_type: Type of Api to create. + + + * ``http`` creates a SOAP to REST API + * ``soap`` creates a SOAP pass-through API . Possible values include: "http", "soap". + :type soap_api_type: str or ~azure.mgmt.apimanagement.models.SoapApiType + """ + + _validation = { + 'api_revision': {'max_length': 100, 'min_length': 1}, + 'api_version': {'max_length': 100, 'min_length': 0}, + 'is_online': {'readonly': True}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'service_url': {'max_length': 2000, 'min_length': 0}, + 'path': {'required': True, 'max_length': 400, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authentication_settings': {'key': 'authenticationSettings', 'type': 'AuthenticationSettingsContract'}, + 'subscription_key_parameter_names': {'key': 'subscriptionKeyParameterNames', 'type': 'SubscriptionKeyParameterNamesContract'}, + 'api_type': {'key': 'type', 'type': 'str'}, + 'api_revision': {'key': 'apiRevision', 'type': 'str'}, + 'api_version': {'key': 'apiVersion', 'type': 'str'}, + 'is_current': {'key': 'isCurrent', 'type': 'bool'}, + 'is_online': {'key': 'isOnline', 'type': 'bool'}, + 'api_revision_description': {'key': 'apiRevisionDescription', 'type': 'str'}, + 'api_version_description': {'key': 'apiVersionDescription', 'type': 'str'}, + 'api_version_set_id': {'key': 'apiVersionSetId', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'source_api_id': {'key': 'sourceApiId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'service_url': {'key': 'serviceUrl', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'protocols': {'key': 'protocols', 'type': '[str]'}, + 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, + 'value': {'key': 'value', 'type': 'str'}, + 'format': {'key': 'format', 'type': 'str'}, + 'wsdl_selector': {'key': 'wsdlSelector', 'type': 'ApiCreateOrUpdatePropertiesWsdlSelector'}, + 'soap_api_type': {'key': 'apiType', 'type': 'str'}, + } + + def __init__( + self, + *, + 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, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + 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, + value: Optional[str] = None, + format: Optional[Union[str, "ContentFormat"]] = None, + wsdl_selector: Optional["ApiCreateOrUpdatePropertiesWsdlSelector"] = None, + soap_api_type: Optional[Union[str, "SoapApiType"]] = None, + **kwargs + ): + super(ApiCreateOrUpdateProperties, self).__init__(description=description, authentication_settings=authentication_settings, subscription_key_parameter_names=subscription_key_parameter_names, api_type=api_type, api_revision=api_revision, api_version=api_version, is_current=is_current, api_revision_description=api_revision_description, api_version_description=api_version_description, api_version_set_id=api_version_set_id, subscription_required=subscription_required, source_api_id=source_api_id, display_name=display_name, service_url=service_url, path=path, protocols=protocols, api_version_set=api_version_set, **kwargs) + self.value = value + self.format = format + self.wsdl_selector = wsdl_selector + self.soap_api_type = soap_api_type + + +class ApiCreateOrUpdatePropertiesWsdlSelector(msrest.serialization.Model): """Criteria to limit import of WSDL to a subset of the document. - :param wsdl_service_name: Name of service to import from WSDL + :param wsdl_service_name: Name of service to import from WSDL. :type wsdl_service_name: str - :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL + :param wsdl_endpoint_name: Name of endpoint(port) to import from WSDL. :type wsdl_endpoint_name: str """ @@ -621,23 +948,28 @@ class ApiCreateOrUpdatePropertiesWsdlSelector(Model): 'wsdl_endpoint_name': {'key': 'wsdlEndpointName', 'type': 'str'}, } - def __init__(self, *, wsdl_service_name: str=None, wsdl_endpoint_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + wsdl_service_name: Optional[str] = None, + wsdl_endpoint_name: Optional[str] = None, + **kwargs + ): super(ApiCreateOrUpdatePropertiesWsdlSelector, self).__init__(**kwargs) self.wsdl_service_name = wsdl_service_name self.wsdl_endpoint_name = wsdl_endpoint_name -class ApiExportResult(Model): +class ApiExportResult(msrest.serialization.Model): """API Export result. :param id: ResourceId of the API which was exported. :type id: str - :param export_result_format: Format in which the Api Details are exported - to the Storage Blob with Sas Key valid for 5 minutes. Possible values - include: 'Swagger', 'Wsdl', 'Wadl', 'OpenApi' - :type export_result_format: str or - ~azure.mgmt.apimanagement.models.ExportResultFormat - :param value: The object defining the schema of the exported Api Detail + :param export_result_format: Format in which the Api Details are exported to the Storage Blob + with Sas Key valid for 5 minutes. Possible values include: "swagger-link-json", "wsdl- + link+xml", "wadl-link-json", "openapi-link". + :type export_result_format: str or ~azure.mgmt.apimanagement.models.ExportResultFormat + :param value: The object defining the schema of the exported Api Detail. :type value: ~azure.mgmt.apimanagement.models.ApiExportResultValue """ @@ -647,18 +979,25 @@ class ApiExportResult(Model): 'value': {'key': 'value', 'type': 'ApiExportResultValue'}, } - def __init__(self, *, id: str=None, export_result_format=None, value=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + export_result_format: Optional[Union[str, "ExportResultFormat"]] = None, + value: Optional["ApiExportResultValue"] = None, + **kwargs + ): super(ApiExportResult, self).__init__(**kwargs) self.id = id self.export_result_format = export_result_format self.value = value -class ApiExportResultValue(Model): +class ApiExportResultValue(msrest.serialization.Model): """The object defining the schema of the exported Api Detail. - :param link: Link to the Storage Blob containing the result of the export - operation. The Blob Uri is only valid for 5 minutes. + :param link: Link to the Storage Blob containing the result of the export operation. The Blob + Uri is only valid for 5 minutes. :type link: str """ @@ -666,17 +1005,21 @@ class ApiExportResultValue(Model): 'link': {'key': 'link', 'type': 'str'}, } - def __init__(self, *, link: str=None, **kwargs) -> None: + def __init__( + self, + *, + link: Optional[str] = None, + **kwargs + ): super(ApiExportResultValue, self).__init__(**kwargs) self.link = link -class ApiManagementServiceApplyNetworkConfigurationParameters(Model): +class ApiManagementServiceApplyNetworkConfigurationParameters(msrest.serialization.Model): """Parameter supplied to the Apply Network configuration operation. - :param location: Location of the Api Management service to update for a - multi-region service. For a service deployed in a single region, this - parameter is not required. + :param location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. :type location: str """ @@ -684,25 +1027,29 @@ class ApiManagementServiceApplyNetworkConfigurationParameters(Model): 'location': {'key': 'location', 'type': 'str'}, } - def __init__(self, *, location: str=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): super(ApiManagementServiceApplyNetworkConfigurationParameters, self).__init__(**kwargs) self.location = location -class ApiManagementServiceBackupRestoreParameters(Model): - """Parameters supplied to the Backup/Restore of an API Management service - operation. +class ApiManagementServiceBackupRestoreParameters(msrest.serialization.Model): + """Parameters supplied to the Backup/Restore of an API Management service operation. All required parameters must be populated in order to send to Azure. - :param storage_account: Required. Azure Cloud Storage account (used to - place/retrieve the backup) name. + :param storage_account: Required. Azure Cloud Storage account (used to place/retrieve the + backup) name. :type storage_account: str - :param access_key: Required. Azure Cloud Storage account (used to - place/retrieve the backup) access key. + :param access_key: Required. Azure Cloud Storage account (used to place/retrieve the backup) + access key. :type access_key: str - :param container_name: Required. Azure Cloud Storage blob container name - used to place/retrieve the backup. + :param container_name: Required. Azure Cloud Storage blob container name used to place/retrieve + the backup. :type container_name: str :param backup_name: Required. The name of the backup file to create. :type backup_name: str @@ -722,7 +1069,15 @@ class ApiManagementServiceBackupRestoreParameters(Model): 'backup_name': {'key': 'backupName', 'type': 'str'}, } - def __init__(self, *, storage_account: str, access_key: str, container_name: str, backup_name: str, **kwargs) -> None: + def __init__( + self, + *, + storage_account: str, + access_key: str, + container_name: str, + backup_name: str, + **kwargs + ): super(ApiManagementServiceBackupRestoreParameters, self).__init__(**kwargs) self.storage_account = storage_account self.access_key = access_key @@ -730,131 +1085,105 @@ def __init__(self, *, storage_account: str, access_key: str, container_name: str self.backup_name = backup_name -class ApiManagementServiceBaseProperties(Model): +class ApiManagementServiceBaseProperties(msrest.serialization.Model): """Base Properties of an API Management service resource description. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param notification_sender_email: Email address from which the - notification will be sent. + :param notification_sender_email: Email address from which the notification will be sent. :type notification_sender_email: str - :ivar provisioning_state: The current provisioning state of the API - Management service which can be one of the following: + :ivar provisioning_state: The current provisioning state of the API Management service which + can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. :vartype provisioning_state: str - :ivar target_provisioning_state: The provisioning state of the API - Management service, which is targeted by the long running operation - started on the service. + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. :vartype target_provisioning_state: str - :ivar created_at_utc: Creation UTC date of the API Management service.The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :vartype created_at_utc: datetime + :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime :ivar gateway_url: Gateway URL of the API Management service. :vartype gateway_url: str - :ivar gateway_regional_url: Gateway URL of the API Management service in - the Default Region. + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. :vartype gateway_regional_url: str - :ivar portal_url: Publisher portal endpoint Url of the API Management - service. + :ivar portal_url: Publisher portal endpoint Url of the API Management service. :vartype portal_url: str - :ivar management_api_url: Management API endpoint URL of the API - Management service. + :ivar management_api_url: Management API endpoint URL of the API Management service. :vartype management_api_url: str :ivar scm_url: SCM endpoint URL of the API Management service. :vartype scm_url: str - :ivar developer_portal_url: DEveloper Portal endpoint URL of the API - Management service. + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. :vartype developer_portal_url: str - :param hostname_configurations: Custom hostname configuration of the API - Management service. - :type hostname_configurations: - list[~azure.mgmt.apimanagement.models.HostnameConfiguration] - :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the - API Management service in Primary region. Available only for Basic, - Standard and Premium SKU. + :param hostname_configurations: Custom hostname configuration of the API Management service. + :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. :vartype public_ip_addresses: list[str] - :ivar private_ip_addresses: Private Static Load Balanced IP addresses of - the API Management service in Primary region which is deployed in an - Internal Virtual Network. Available only for Basic, Standard and Premium - SKU. + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. :vartype private_ip_addresses: list[str] - :param virtual_network_configuration: Virtual network configuration of the - API Management service. + :param virtual_network_configuration: Virtual network configuration of the API Management + service. :type virtual_network_configuration: ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration - :param additional_locations: Additional datacenter locations of the API - Management service. - :type additional_locations: - list[~azure.mgmt.apimanagement.models.AdditionalLocation] - :param custom_properties: Custom properties of the API Management - service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168` - will disable the cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 - and 1.2).
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11` - can be used to disable just TLS 1.1.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10` - can be used to disable TLS 1.0 on an API Management service.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11` - can be used to disable just TLS 1.1 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10` - can be used to disable TLS 1.0 for communications with - backends.
Setting - `Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2` can - be used to enable HTTP2 protocol on an API Management service.
Not - specifying any of these properties on PATCH operation will reset omitted - properties' values to their defaults. For all the settings except Http2 - the default value is `True` if the service was created on or before April - 1st 2018 and `False` otherwise. Http2 setting's default value is - `False`.

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

You can + disable any of next ciphers by using settings `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: - TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, - TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, - TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. For example, - `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:`false`. - The default value is `true` for them. Note: next ciphers can't be - disabled since they are required by Azure CloudService internal - components: - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384 + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. :type custom_properties: dict[str, str] - :param certificates: List of Certificates that need to be installed in the - API Management service. Max supported certificates that can be installed - is 10. - :type certificates: - list[~azure.mgmt.apimanagement.models.CertificateConfiguration] - :param enable_client_certificate: Property only meant to be used for - Consumption SKU Service. This enforces a client certificate to be - presented on each request to the gateway. This also enables the ability to - authenticate the certificate in the policy on the gateway. Default value: - False . + :param certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. :type enable_client_certificate: bool - :param disable_gateway: Property only valid for an Api Management service - deployed in multiple locations. This can be used to disable the gateway in - master region. Default value: False . + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. :type disable_gateway: bool - :param virtual_network_type: The type of VPN in which API Management - service needs to be configured in. None (Default Value) means the API - Management service is not part of any Virtual Network, External means the - API Management deployment is set up inside a Virtual Network having an - Internet Facing Endpoint, and Internal means that API Management - deployment is setup inside a Virtual Network having an Intranet Facing - Endpoint only. Possible values include: 'None', 'External', 'Internal'. - Default value: "None" . - :type virtual_network_type: str or - ~azure.mgmt.apimanagement.models.VirtualNetworkType - :param api_version_constraint: Control Plane Apis version constraint for - the API Management service. - :type api_version_constraint: - ~azure.mgmt.apimanagement.models.ApiVersionConstraint - """ - - _validation = { - 'notification_sender_email': {'max_length': 100}, + :param virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :param api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :type restore: bool + """ + + _validation = { + 'notification_sender_email': {'max_length': 100, 'min_length': 0}, 'provisioning_state': {'readonly': True}, 'target_provisioning_state': {'readonly': True}, 'created_at_utc': {'readonly': True}, @@ -890,9 +1219,25 @@ class ApiManagementServiceBaseProperties(Model): 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, 'virtual_network_type': {'key': 'virtualNetworkType', 'type': 'str'}, 'api_version_constraint': {'key': 'apiVersionConstraint', 'type': 'ApiVersionConstraint'}, - } - - def __init__(self, *, notification_sender_email: str=None, hostname_configurations=None, virtual_network_configuration=None, additional_locations=None, custom_properties=None, certificates=None, enable_client_certificate: bool=False, disable_gateway: bool=False, virtual_network_type="None", api_version_constraint=None, **kwargs) -> None: + 'restore': {'key': 'restore', 'type': 'bool'}, + } + + def __init__( + self, + *, + notification_sender_email: Optional[str] = None, + hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["AdditionalLocation"]] = None, + custom_properties: Optional[Dict[str, str]] = None, + certificates: Optional[List["CertificateConfiguration"]] = None, + enable_client_certificate: Optional[bool] = False, + disable_gateway: Optional[bool] = False, + virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", + api_version_constraint: Optional["ApiVersionConstraint"] = None, + restore: Optional[bool] = False, + **kwargs + ): super(ApiManagementServiceBaseProperties, self).__init__(**kwargs) self.notification_sender_email = notification_sender_email self.provisioning_state = None @@ -915,9 +1260,10 @@ def __init__(self, *, notification_sender_email: str=None, hostname_configuratio self.disable_gateway = disable_gateway self.virtual_network_type = virtual_network_type self.api_version_constraint = api_version_constraint + self.restore = restore -class ApiManagementServiceCheckNameAvailabilityParameters(Model): +class ApiManagementServiceCheckNameAvailabilityParameters(msrest.serialization.Model): """Parameters supplied to the CheckNameAvailability operation. All required parameters must be populated in order to send to Azure. @@ -934,16 +1280,20 @@ class ApiManagementServiceCheckNameAvailabilityParameters(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, name: str, **kwargs) -> None: + def __init__( + self, + *, + name: str, + **kwargs + ): super(ApiManagementServiceCheckNameAvailabilityParameters, self).__init__(**kwargs) self.name = name -class ApiManagementServiceGetSsoTokenResult(Model): +class ApiManagementServiceGetSsoTokenResult(msrest.serialization.Model): """The response of the GetSsoToken operation. - :param redirect_uri: Redirect URL to the Publisher Portal containing the - SSO token. + :param redirect_uri: Redirect URL to the Publisher Portal containing the SSO token. :type redirect_uri: str """ @@ -951,34 +1301,37 @@ class ApiManagementServiceGetSsoTokenResult(Model): 'redirect_uri': {'key': 'redirectUri', 'type': 'str'}, } - def __init__(self, *, redirect_uri: str=None, **kwargs) -> None: + def __init__( + self, + *, + redirect_uri: Optional[str] = None, + **kwargs + ): super(ApiManagementServiceGetSsoTokenResult, self).__init__(**kwargs) self.redirect_uri = redirect_uri -class ApiManagementServiceIdentity(Model): +class ApiManagementServiceIdentity(msrest.serialization.Model): """Identity properties of the Api Management service resource. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param type: Required. The type of identity used for the resource. The - type 'SystemAssigned, UserAssigned' includes both an implicitly created - identity and a set of user assigned identities. The type 'None' will - remove any identities from the service. Possible values include: - 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned', 'None' + :param type: Required. The type of identity used for the resource. The type 'SystemAssigned, + UserAssigned' includes both an implicitly created identity and a set of user assigned + identities. The type 'None' will remove any identities from the service. Possible values + include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :type type: str or ~azure.mgmt.apimanagement.models.ApimIdentityType :ivar principal_id: The principal id of the identity. :vartype principal_id: str :ivar tenant_id: The client tenant id of the identity. :vartype tenant_id: str - :param user_assigned_identities: The list of user identities associated - with the resource. The user identity + :param user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ - providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. :type user_assigned_identities: dict[str, ~azure.mgmt.apimanagement.models.UserIdentityProperties] """ @@ -996,7 +1349,13 @@ class ApiManagementServiceIdentity(Model): 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, } - def __init__(self, *, type, user_assigned_identities=None, **kwargs) -> None: + def __init__( + self, + *, + type: Union[str, "ApimIdentityType"], + user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + **kwargs + ): super(ApiManagementServiceIdentity, self).__init__(**kwargs) self.type = type self.principal_id = None @@ -1004,28 +1363,57 @@ def __init__(self, *, type, user_assigned_identities=None, **kwargs) -> None: self.user_assigned_identities = user_assigned_identities -class ApiManagementServiceNameAvailabilityResult(Model): +class ApiManagementServiceListResult(msrest.serialization.Model): + """The response of the List API Management services operation. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. Result of the List API Management services operation. + :type value: list[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + of API Management services. + :type next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiManagementServiceResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ApiManagementServiceResource"], + next_link: Optional[str] = None, + **kwargs + ): + super(ApiManagementServiceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ApiManagementServiceNameAvailabilityResult(msrest.serialization.Model): """Response of the CheckNameAvailability operation. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar name_available: True if the name is available and can be used to - create a new API Management service; otherwise false. + :ivar name_available: True if the name is available and can be used to create a new API + Management service; otherwise false. :vartype name_available: bool - :ivar message: If reason == invalid, provide the user with the reason why - the given name is invalid, and provide the resource naming requirements so - that the user can select a valid name. If reason == AlreadyExists, explain - that is already in use, and direct them to select a - different name. + :ivar message: If reason == invalid, provide the user with the reason why the given name is + invalid, and provide the resource naming requirements so that the user can select a valid name. + If reason == AlreadyExists, explain that :code:`` is already in use, and direct + them to select a different name. :vartype message: str - :param reason: Invalid indicates the name provided does not match the - resource provider’s naming requirements (incorrect length, unsupported - characters, etc.) AlreadyExists indicates that the name is already in use - and is therefore unavailable. Possible values include: 'Valid', 'Invalid', - 'AlreadyExists' - :type reason: str or - ~azure.mgmt.apimanagement.models.NameAvailabilityReason + :param reason: Invalid indicates the name provided does not match the resource provider’s + naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists indicates + that the name is already in use and is therefore unavailable. Possible values include: "Valid", + "Invalid", "AlreadyExists". + :type reason: str or ~azure.mgmt.apimanagement.models.NameAvailabilityReason """ _validation = { @@ -1036,30 +1424,203 @@ class ApiManagementServiceNameAvailabilityResult(Model): _attribute_map = { 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, 'message': {'key': 'message', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'NameAvailabilityReason'}, + 'reason': {'key': 'reason', 'type': 'str'}, } - def __init__(self, *, reason=None, **kwargs) -> None: + def __init__( + self, + *, + reason: Optional[Union[str, "NameAvailabilityReason"]] = None, + **kwargs + ): super(ApiManagementServiceNameAvailabilityResult, self).__init__(**kwargs) self.name_available = None self.message = None self.reason = reason -class ApimResource(Model): +class ApiManagementServiceProperties(ApiManagementServiceBaseProperties): + """Properties of an API Management service resource description. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param notification_sender_email: Email address from which the notification will be sent. + :type notification_sender_email: str + :ivar provisioning_state: The current provisioning state of the API Management service which + can be one of the following: + Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + :vartype provisioning_state: str + :ivar target_provisioning_state: The provisioning state of the API Management service, which is + targeted by the long running operation started on the service. + :vartype target_provisioning_state: str + :ivar created_at_utc: Creation UTC date of the API Management service.The date conforms to the + following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_at_utc: ~datetime.datetime + :ivar gateway_url: Gateway URL of the API Management service. + :vartype gateway_url: str + :ivar gateway_regional_url: Gateway URL of the API Management service in the Default Region. + :vartype gateway_regional_url: str + :ivar portal_url: Publisher portal endpoint Url of the API Management service. + :vartype portal_url: str + :ivar management_api_url: Management API endpoint URL of the API Management service. + :vartype management_api_url: str + :ivar scm_url: SCM endpoint URL of the API Management service. + :vartype scm_url: str + :ivar developer_portal_url: DEveloper Portal endpoint URL of the API Management service. + :vartype developer_portal_url: str + :param hostname_configurations: Custom hostname configuration of the API Management service. + :type hostname_configurations: list[~azure.mgmt.apimanagement.models.HostnameConfiguration] + :ivar public_ip_addresses: Public Static Load Balanced IP addresses of the API Management + service in Primary region. Available only for Basic, Standard, Premium and Isolated SKU. + :vartype public_ip_addresses: list[str] + :ivar private_ip_addresses: Private Static Load Balanced IP addresses of the API Management + service in Primary region which is deployed in an Internal Virtual Network. Available only for + Basic, Standard, Premium and Isolated SKU. + :vartype private_ip_addresses: list[str] + :param virtual_network_configuration: Virtual network configuration of the API Management + service. + :type virtual_network_configuration: + ~azure.mgmt.apimanagement.models.VirtualNetworkConfiguration + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

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

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

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

You can disable any of next ciphers by using settings + :param additional_locations: Additional datacenter locations of the API Management service. + :type additional_locations: list[~azure.mgmt.apimanagement.models.AdditionalLocation] + :param custom_properties: Custom properties of the API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168`` will disable the + cipher TLS_RSA_WITH_3DES_EDE_CBC_SHA for all TLS(1.0, 1.1 and 1.2).
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11`` can be used to + disable just TLS 1.1.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10`` can be used to + disable TLS 1.0 on an API Management service.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11`` can be used + to disable just TLS 1.1 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10`` can be used + to disable TLS 1.0 for communications with backends.
Setting + ``Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2`` can be used to enable + HTTP2 protocol on an API Management service.
Not specifying any of these properties on + PATCH operation will reset omitted properties' values to their defaults. For all the settings + except Http2 the default value is ``True`` if the service was created on or before April 1st + 2018 and ``False`` otherwise. Http2 setting's default value is ``False``.

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

You can + disable any of next ciphers by using settings + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]`: + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, + TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, + TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA. + For example, + `Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256`:\ + ``false``. The default value is ``true`` for them. Note: next ciphers can't be disabled since + they are required by Azure CloudService internal components: + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384. + :type custom_properties: dict[str, str] + :param certificates: List of Certificates that need to be installed in the API Management + service. Max supported certificates that can be installed is 10. + :type certificates: list[~azure.mgmt.apimanagement.models.CertificateConfiguration] + :param enable_client_certificate: Property only meant to be used for Consumption SKU Service. + This enforces a client certificate to be presented on each request to the gateway. This also + enables the ability to authenticate the certificate in the policy on the gateway. + :type enable_client_certificate: bool + :param disable_gateway: Property only valid for an Api Management service deployed in multiple + locations. This can be used to disable the gateway in master region. + :type disable_gateway: bool + :param virtual_network_type: The type of VPN in which API Management service needs to be + configured in. None (Default Value) means the API Management service is not part of any Virtual + Network, External means the API Management deployment is set up inside a Virtual Network having + an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside + a Virtual Network having an Intranet Facing Endpoint only. Possible values include: "None", + "External", "Internal". Default value: "None". + :type virtual_network_type: str or ~azure.mgmt.apimanagement.models.VirtualNetworkType + :param api_version_constraint: Control Plane Apis version constraint for the API Management + service. + :type api_version_constraint: ~azure.mgmt.apimanagement.models.ApiVersionConstraint + :param restore: Undelete Api Management Service if it was previously soft-deleted. If this flag + is specified and set to True all other properties will be ignored. + :type restore: bool + :param publisher_email: Publisher email. + :type publisher_email: str + :param publisher_name: Publisher name. + :type publisher_name: str + """ + + _validation = { + 'notification_sender_email': {'max_length': 100, 'min_length': 0}, + 'provisioning_state': {'readonly': True}, + 'target_provisioning_state': {'readonly': True}, + 'created_at_utc': {'readonly': True}, + 'gateway_url': {'readonly': True}, + 'gateway_regional_url': {'readonly': True}, + 'portal_url': {'readonly': True}, + 'management_api_url': {'readonly': True}, + 'scm_url': {'readonly': True}, + 'developer_portal_url': {'readonly': True}, + 'public_ip_addresses': {'readonly': True}, + 'private_ip_addresses': {'readonly': True}, + 'publisher_email': {'max_length': 100, 'min_length': 0}, + 'publisher_name': {'max_length': 100, 'min_length': 0}, + } + + _attribute_map = { + 'notification_sender_email': {'key': 'notificationSenderEmail', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'target_provisioning_state': {'key': 'targetProvisioningState', 'type': 'str'}, + 'created_at_utc': {'key': 'createdAtUtc', 'type': 'iso-8601'}, + 'gateway_url': {'key': 'gatewayUrl', 'type': 'str'}, + 'gateway_regional_url': {'key': 'gatewayRegionalUrl', 'type': 'str'}, + 'portal_url': {'key': 'portalUrl', 'type': 'str'}, + 'management_api_url': {'key': 'managementApiUrl', 'type': 'str'}, + 'scm_url': {'key': 'scmUrl', 'type': 'str'}, + 'developer_portal_url': {'key': 'developerPortalUrl', 'type': 'str'}, + 'hostname_configurations': {'key': 'hostnameConfigurations', 'type': '[HostnameConfiguration]'}, + 'public_ip_addresses': {'key': 'publicIPAddresses', 'type': '[str]'}, + 'private_ip_addresses': {'key': 'privateIPAddresses', 'type': '[str]'}, + 'virtual_network_configuration': {'key': 'virtualNetworkConfiguration', 'type': 'VirtualNetworkConfiguration'}, + 'additional_locations': {'key': 'additionalLocations', 'type': '[AdditionalLocation]'}, + 'custom_properties': {'key': 'customProperties', 'type': '{str}'}, + 'certificates': {'key': 'certificates', 'type': '[CertificateConfiguration]'}, + 'enable_client_certificate': {'key': 'enableClientCertificate', 'type': 'bool'}, + 'disable_gateway': {'key': 'disableGateway', 'type': 'bool'}, + 'virtual_network_type': {'key': 'virtualNetworkType', 'type': 'str'}, + 'api_version_constraint': {'key': 'apiVersionConstraint', 'type': 'ApiVersionConstraint'}, + 'restore': {'key': 'restore', 'type': 'bool'}, + 'publisher_email': {'key': 'publisherEmail', 'type': 'str'}, + 'publisher_name': {'key': 'publisherName', 'type': 'str'}, + } + + def __init__( + self, + *, + notification_sender_email: Optional[str] = None, + hostname_configurations: Optional[List["HostnameConfiguration"]] = None, + virtual_network_configuration: Optional["VirtualNetworkConfiguration"] = None, + additional_locations: Optional[List["AdditionalLocation"]] = None, + custom_properties: Optional[Dict[str, str]] = None, + certificates: Optional[List["CertificateConfiguration"]] = None, + enable_client_certificate: Optional[bool] = False, + disable_gateway: Optional[bool] = False, + virtual_network_type: Optional[Union[str, "VirtualNetworkType"]] = "None", + api_version_constraint: Optional["ApiVersionConstraint"] = None, + restore: Optional[bool] = False, + publisher_email: Optional[str] = None, + publisher_name: Optional[str] = None, + **kwargs + ): + super(ApiManagementServiceUpdateProperties, self).__init__(notification_sender_email=notification_sender_email, hostname_configurations=hostname_configurations, virtual_network_configuration=virtual_network_configuration, additional_locations=additional_locations, custom_properties=custom_properties, certificates=certificates, enable_client_certificate=enable_client_certificate, disable_gateway=disable_gateway, virtual_network_type=virtual_network_type, api_version_constraint=api_version_constraint, restore=restore, **kwargs) + self.publisher_email = publisher_email + self.publisher_name = publisher_name + + +class ApiReleaseCollection(msrest.serialization.Model): + """Paged ApiRelease list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiReleaseContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiReleaseContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiReleaseCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None class ApiReleaseContract(Resource): """ApiRelease details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -1591,13 +2352,12 @@ class ApiReleaseContract(Resource): :vartype type: str :param api_id: Identifier of the API the release belongs to. :type api_id: str - :ivar created_date_time: The time the API was released. The date conforms - to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 - standard. - :vartype created_date_time: datetime + :ivar created_date_time: The time the API was released. The date conforms to the following + format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime :ivar updated_date_time: The time the API release was updated. - :vartype updated_date_time: datetime - :param notes: Release Notes + :vartype updated_date_time: ~datetime.datetime + :param notes: Release Notes. :type notes: str """ @@ -1619,7 +2379,13 @@ class ApiReleaseContract(Resource): 'notes': {'key': 'properties.notes', 'type': 'str'}, } - def __init__(self, *, api_id: str=None, notes: str=None, **kwargs) -> None: + def __init__( + self, + *, + api_id: Optional[str] = None, + notes: Optional[str] = None, + **kwargs + ): super(ApiReleaseContract, self).__init__(**kwargs) self.api_id = api_id self.created_date_time = None @@ -1627,24 +2393,51 @@ def __init__(self, *, api_id: str=None, notes: str=None, **kwargs) -> None: self.notes = notes -class ApiRevisionContract(Model): +class ApiRevisionCollection(msrest.serialization.Model): + """Paged Api Revision list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.ApiRevisionContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiRevisionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ApiRevisionCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ApiRevisionContract(msrest.serialization.Model): """Summary of revision metadata. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar api_id: Identifier of the API Revision. :vartype api_id: str :ivar api_revision: Revision number of API. :vartype api_revision: str - :ivar created_date_time: The time the API Revision was created. The date - conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the - ISO 8601 standard. - :vartype created_date_time: datetime - :ivar updated_date_time: The time the API Revision were updated. The date - conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the - ISO 8601 standard. - :vartype updated_date_time: datetime + :ivar created_date_time: The time the API Revision was created. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype created_date_time: ~datetime.datetime + :ivar updated_date_time: The time the API Revision were updated. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype updated_date_time: ~datetime.datetime :ivar description: Description of the API Revision. :vartype description: str :ivar private_url: Gateway URL for accessing the non-current API Revision. @@ -1660,7 +2453,7 @@ class ApiRevisionContract(Model): 'api_revision': {'readonly': True, 'max_length': 100, 'min_length': 1}, 'created_date_time': {'readonly': True}, 'updated_date_time': {'readonly': True}, - 'description': {'readonly': True, 'max_length': 256}, + 'description': {'readonly': True, 'max_length': 256, 'min_length': 0}, 'private_url': {'readonly': True}, 'is_online': {'readonly': True}, 'is_current': {'readonly': True}, @@ -1677,7 +2470,10 @@ class ApiRevisionContract(Model): 'is_current': {'key': 'isCurrent', 'type': 'bool'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ApiRevisionContract, self).__init__(**kwargs) self.api_id = None self.api_revision = None @@ -1689,25 +2485,22 @@ def __init__(self, **kwargs) -> None: self.is_current = None -class ApiRevisionInfoContract(Model): - """Object used to create an API Revision or Version based on an existing API - Revision. +class ApiRevisionInfoContract(msrest.serialization.Model): + """Object used to create an API Revision or Version based on an existing API Revision. - :param source_api_id: Resource identifier of API to be used to create the - revision from. + :param source_api_id: Resource identifier of API to be used to create the revision from. :type source_api_id: str :param api_version_name: Version identifier for the new API Version. :type api_version_name: str :param api_revision_description: Description of new API Revision. :type api_revision_description: str - :param api_version_set: Version set details - :type api_version_set: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails + :param api_version_set: Version set details. + :type api_version_set: ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetails """ _validation = { - 'api_version_name': {'max_length': 100}, - 'api_revision_description': {'max_length': 256}, + 'api_version_name': {'max_length': 100, 'min_length': 0}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -1717,7 +2510,15 @@ class ApiRevisionInfoContract(Model): 'api_version_set': {'key': 'apiVersionSet', 'type': 'ApiVersionSetContractDetails'}, } - def __init__(self, *, source_api_id: str=None, api_version_name: str=None, api_revision_description: str=None, api_version_set=None, **kwargs) -> None: + def __init__( + self, + *, + source_api_id: Optional[str] = None, + api_version_name: Optional[str] = None, + api_revision_description: Optional[str] = None, + api_version_set: Optional["ApiVersionSetContractDetails"] = None, + **kwargs + ): super(ApiRevisionInfoContract, self).__init__(**kwargs) self.source_api_id = source_api_id self.api_version_name = api_version_name @@ -1728,27 +2529,21 @@ def __init__(self, *, source_api_id: str=None, api_version_name: str=None, api_r class ApiTagResourceContractProperties(ApiEntityBaseContract): """API contract properties for the Tag Resources. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -1758,35 +2553,31 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param id: API identifier in the form /apis/{apiId}. :type id: str :param name: API name. :type name: str - :param service_url: Absolute URL of the backend service implementing this - API. + :param service_url: Absolute URL of the backend service implementing this API. :type service_url: str - :param path: Relative URL uniquely identifying this API and all of its - resource paths within the API Management service instance. It is appended - to the API endpoint base URL specified during the service instance - creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 1}, 'path': {'max_length': 400, 'min_length': 0}, @@ -1809,10 +2600,30 @@ class ApiTagResourceContractProperties(ApiEntityBaseContract): 'name': {'key': 'name', 'type': 'str'}, 'service_url': {'key': 'serviceUrl', 'type': 'str'}, 'path': {'key': 'path', 'type': 'str'}, - 'protocols': {'key': 'protocols', 'type': '[Protocol]'}, - } - - def __init__(self, *, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, id: str=None, name: str=None, service_url: str=None, path: str=None, protocols=None, **kwargs) -> None: + 'protocols': {'key': 'protocols', 'type': '[str]'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + id: Optional[str] = None, + name: Optional[str] = None, + service_url: Optional[str] = None, + path: Optional[str] = None, + protocols: Optional[List[Union[str, "Protocol"]]] = None, + **kwargs + ): super(ApiTagResourceContractProperties, self).__init__(description=description, authentication_settings=authentication_settings, subscription_key_parameter_names=subscription_key_parameter_names, api_type=api_type, api_revision=api_revision, api_version=api_version, is_current=is_current, api_revision_description=api_revision_description, api_version_description=api_version_description, api_version_set_id=api_version_set_id, subscription_required=subscription_required, **kwargs) self.id = id self.name = name @@ -1821,30 +2632,24 @@ def __init__(self, *, description: str=None, authentication_settings=None, subsc self.protocols = protocols -class ApiUpdateContract(Model): +class ApiUpdateContract(msrest.serialization.Model): """API update contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the API. May include HTML formatting - tags. + :param description: Description of the API. May include HTML formatting tags. :type description: str - :param authentication_settings: Collection of authentication settings - included into this API. - :type authentication_settings: - ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract - :param subscription_key_parameter_names: Protocols over which API is made - available. + :param authentication_settings: Collection of authentication settings included into this API. + :type authentication_settings: ~azure.mgmt.apimanagement.models.AuthenticationSettingsContract + :param subscription_key_parameter_names: Protocols over which API is made available. :type subscription_key_parameter_names: ~azure.mgmt.apimanagement.models.SubscriptionKeyParameterNamesContract - :param api_type: Type of API. Possible values include: 'http', 'soap' + :param api_type: Type of API. Possible values include: "http", "soap". :type api_type: str or ~azure.mgmt.apimanagement.models.ApiType - :param api_revision: Describes the Revision of the Api. If no value is - provided, default revision 1 is created + :param api_revision: Describes the Revision of the Api. If no value is provided, default + revision 1 is created. :type api_revision: str - :param api_version: Indicates the Version identifier of the API if the API - is versioned + :param api_version: Indicates the Version identifier of the API if the API is versioned. :type api_version: str :param is_current: Indicates if API revision is current api revision. :type is_current: bool @@ -1854,33 +2659,29 @@ class ApiUpdateContract(Model): :type api_revision_description: str :param api_version_description: Description of the Api Version. :type api_version_description: str - :param api_version_set_id: A resource identifier for the related - ApiVersionSet. + :param api_version_set_id: A resource identifier for the related ApiVersionSet. :type api_version_set_id: str - :param subscription_required: Specifies whether an API or Product - subscription is required for accessing the API. + :param subscription_required: Specifies whether an API or Product subscription is required for + accessing the API. :type subscription_required: bool :param display_name: API name. :type display_name: str - :param service_url: Absolute URL of the backend service implementing this - API. + :param service_url: Absolute URL of the backend service implementing this API. :type service_url: str - :param path: Relative URL uniquely identifying this API and all of its - resource paths within the API Management service instance. It is appended - to the API endpoint base URL specified during the service instance - creation to form a public URL for this API. + :param path: Relative URL uniquely identifying this API and all of its resource paths within + the API Management service instance. It is appended to the API endpoint base URL specified + during the service instance creation to form a public URL for this API. :type path: str - :param protocols: Describes on which protocols the operations in this API - can be invoked. + :param protocols: Describes on which protocols the operations in this API can be invoked. :type protocols: list[str or ~azure.mgmt.apimanagement.models.Protocol] """ _validation = { 'api_revision': {'max_length': 100, 'min_length': 1}, - 'api_version': {'max_length': 100}, + 'api_version': {'max_length': 100, 'min_length': 0}, 'is_online': {'readonly': True}, - 'api_revision_description': {'max_length': 256}, - 'api_version_description': {'max_length': 256}, + 'api_revision_description': {'max_length': 256, 'min_length': 0}, + 'api_version_description': {'max_length': 256, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'service_url': {'max_length': 2000, 'min_length': 1}, 'path': {'max_length': 400, 'min_length': 0}, @@ -1902,10 +2703,29 @@ class ApiUpdateContract(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'service_url': {'key': 'properties.serviceUrl', 'type': 'str'}, 'path': {'key': 'properties.path', 'type': 'str'}, - 'protocols': {'key': 'properties.protocols', 'type': '[Protocol]'}, - } - - def __init__(self, *, description: str=None, authentication_settings=None, subscription_key_parameter_names=None, api_type=None, api_revision: str=None, api_version: str=None, is_current: bool=None, api_revision_description: str=None, api_version_description: str=None, api_version_set_id: str=None, subscription_required: bool=None, display_name: str=None, service_url: str=None, path: str=None, protocols=None, **kwargs) -> None: + 'protocols': {'key': 'properties.protocols', 'type': '[str]'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + authentication_settings: Optional["AuthenticationSettingsContract"] = None, + subscription_key_parameter_names: Optional["SubscriptionKeyParameterNamesContract"] = None, + api_type: Optional[Union[str, "ApiType"]] = None, + api_revision: Optional[str] = None, + api_version: Optional[str] = None, + is_current: Optional[bool] = None, + api_revision_description: Optional[str] = None, + api_version_description: Optional[str] = None, + api_version_set_id: Optional[str] = None, + subscription_required: Optional[bool] = None, + display_name: Optional[str] = None, + service_url: Optional[str] = None, + path: Optional[str] = None, + protocols: Optional[List[Union[str, "Protocol"]]] = None, + **kwargs + ): super(ApiUpdateContract, self).__init__(**kwargs) self.description = description self.authentication_settings = authentication_settings @@ -1925,11 +2745,11 @@ def __init__(self, *, description: str=None, authentication_settings=None, subsc self.protocols = protocols -class ApiVersionConstraint(Model): +class ApiVersionConstraint(msrest.serialization.Model): """Control Plane Apis version constraint for the API Management service. - :param min_api_version: Limit control plane API calls to API Management - service with version equal to or newer than this value. + :param min_api_version: Limit control plane API calls to API Management service with version + equal to or newer than this value. :type min_api_version: str """ @@ -1937,18 +2757,46 @@ class ApiVersionConstraint(Model): 'min_api_version': {'key': 'minApiVersion', 'type': 'str'}, } - def __init__(self, *, min_api_version: str=None, **kwargs) -> None: + def __init__( + self, + *, + min_api_version: Optional[str] = None, + **kwargs + ): super(ApiVersionConstraint, self).__init__(**kwargs) self.min_api_version = min_api_version +class ApiVersionSetCollection(msrest.serialization.Model): + """Paged Api Version Set list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ApiVersionSetContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ApiVersionSetContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ApiVersionSetContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ApiVersionSetCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class ApiVersionSetContract(Resource): """Api Version Set Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -1958,19 +2806,17 @@ class ApiVersionSetContract(Resource): :vartype type: str :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str - :param display_name: Required. Name of API Version Set + :param display_name: Name of API Version Set. :type display_name: str - :param versioning_scheme: Required. An value that determines where the API - Version identifer will be located in a HTTP request. Possible values - include: 'Segment', 'Query', 'Header' - :type versioning_scheme: str or - ~azure.mgmt.apimanagement.models.VersioningScheme + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -1979,8 +2825,7 @@ class ApiVersionSetContract(Resource): 'type': {'readonly': True}, 'version_query_name': {'max_length': 100, 'min_length': 1}, 'version_header_name': {'max_length': 100, 'min_length': 1}, - 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, - 'versioning_scheme': {'required': True}, + 'display_name': {'max_length': 100, 'min_length': 1}, } _attribute_map = { @@ -1994,7 +2839,16 @@ class ApiVersionSetContract(Resource): 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, } - def __init__(self, *, display_name: str, versioning_scheme, description: str=None, version_query_name: str=None, version_header_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + display_name: Optional[str] = None, + versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + **kwargs + ): super(ApiVersionSetContract, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name @@ -2003,26 +2857,25 @@ def __init__(self, *, display_name: str, versioning_scheme, description: str=Non self.versioning_scheme = versioning_scheme -class ApiVersionSetContractDetails(Model): - """An API Version Set contains the common configuration for a set of API - Versions relating . +class ApiVersionSetContractDetails(msrest.serialization.Model): + """An API Version Set contains the common configuration for a set of API Versions relating. - :param id: Identifier for existing API Version Set. Omit this value to - create a new Version Set. + :param id: Identifier for existing API Version Set. Omit this value to create a new Version + Set. :type id: str :param name: The display Name of the API Version Set. :type name: str :param description: Description of API Version Set. :type description: str - :param versioning_scheme: An value that determines where the API Version - identifer will be located in a HTTP request. Possible values include: - 'Segment', 'Query', 'Header' - :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.enum - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or + ~azure.mgmt.apimanagement.models.ApiVersionSetContractDetailsVersioningScheme + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str """ @@ -2035,7 +2888,17 @@ class ApiVersionSetContractDetails(Model): 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, } - def __init__(self, *, id: str=None, name: str=None, description: str=None, versioning_scheme=None, version_query_name: str=None, version_header_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + versioning_scheme: Optional[Union[str, "ApiVersionSetContractDetailsVersioningScheme"]] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + **kwargs + ): super(ApiVersionSetContractDetails, self).__init__(**kwargs) self.id = id self.name = name @@ -2045,16 +2908,16 @@ def __init__(self, *, id: str=None, name: str=None, description: str=None, versi self.version_header_name = version_header_name -class ApiVersionSetEntityBase(Model): +class ApiVersionSetEntityBase(msrest.serialization.Model): """Api Version set base parameters. :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str """ @@ -2069,31 +2932,86 @@ class ApiVersionSetEntityBase(Model): 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, } - def __init__(self, *, description: str=None, version_query_name: str=None, version_header_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + **kwargs + ): super(ApiVersionSetEntityBase, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name self.version_header_name = version_header_name -class ApiVersionSetUpdateParameters(Model): +class ApiVersionSetContractProperties(ApiVersionSetEntityBase): + """Properties of an API Version Set. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of API Version Set. + :type description: str + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :type version_query_name: str + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :type version_header_name: str + :param display_name: Required. Name of API Version Set. + :type display_name: str + :param versioning_scheme: Required. An value that determines where the API Version identifer + will be located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ + + _validation = { + 'version_query_name': {'max_length': 100, 'min_length': 1}, + 'version_header_name': {'max_length': 100, 'min_length': 1}, + 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'versioning_scheme': {'required': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, + 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: str, + versioning_scheme: Union[str, "VersioningScheme"], + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + **kwargs + ): + super(ApiVersionSetContractProperties, self).__init__(description=description, version_query_name=version_query_name, version_header_name=version_header_name, **kwargs) + self.display_name = display_name + self.versioning_scheme = versioning_scheme + + +class ApiVersionSetUpdateParameters(msrest.serialization.Model): """Parameters to update or create an Api Version Set Contract. :param description: Description of API Version Set. :type description: str - :param version_query_name: Name of query parameter that indicates the API - Version if versioningScheme is set to `query`. + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. :type version_query_name: str - :param version_header_name: Name of HTTP header parameter that indicates - the API Version if versioningScheme is set to `header`. + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. :type version_header_name: str - :param display_name: Name of API Version Set + :param display_name: Name of API Version Set. :type display_name: str - :param versioning_scheme: An value that determines where the API Version - identifer will be located in a HTTP request. Possible values include: - 'Segment', 'Query', 'Header' - :type versioning_scheme: str or - ~azure.mgmt.apimanagement.models.VersioningScheme + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme """ _validation = { @@ -2110,7 +3028,16 @@ class ApiVersionSetUpdateParameters(Model): 'versioning_scheme': {'key': 'properties.versioningScheme', 'type': 'str'}, } - def __init__(self, *, description: str=None, version_query_name: str=None, version_header_name: str=None, display_name: str=None, versioning_scheme=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + display_name: Optional[str] = None, + versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + **kwargs + ): super(ApiVersionSetUpdateParameters, self).__init__(**kwargs) self.description = description self.version_query_name = version_query_name @@ -2119,11 +3046,57 @@ def __init__(self, *, description: str=None, version_query_name: str=None, versi self.versioning_scheme = versioning_scheme +class ApiVersionSetUpdateParametersProperties(ApiVersionSetEntityBase): + """Properties used to create or update an API Version Set. + + :param description: Description of API Version Set. + :type description: str + :param version_query_name: Name of query parameter that indicates the API Version if + versioningScheme is set to ``query``. + :type version_query_name: str + :param version_header_name: Name of HTTP header parameter that indicates the API Version if + versioningScheme is set to ``header``. + :type version_header_name: str + :param display_name: Name of API Version Set. + :type display_name: str + :param versioning_scheme: An value that determines where the API Version identifer will be + located in a HTTP request. Possible values include: "Segment", "Query", "Header". + :type versioning_scheme: str or ~azure.mgmt.apimanagement.models.VersioningScheme + """ + + _validation = { + 'version_query_name': {'max_length': 100, 'min_length': 1}, + 'version_header_name': {'max_length': 100, 'min_length': 1}, + 'display_name': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'version_query_name': {'key': 'versionQueryName', 'type': 'str'}, + 'version_header_name': {'key': 'versionHeaderName', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'versioning_scheme': {'key': 'versioningScheme', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + version_query_name: Optional[str] = None, + version_header_name: Optional[str] = None, + display_name: Optional[str] = None, + versioning_scheme: Optional[Union[str, "VersioningScheme"]] = None, + **kwargs + ): + super(ApiVersionSetUpdateParametersProperties, self).__init__(description=description, version_query_name=version_query_name, version_header_name=version_header_name, **kwargs) + self.display_name = display_name + self.versioning_scheme = versioning_scheme + + class AssociationContract(Resource): """Association entity details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2131,39 +3104,40 @@ class AssociationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param provisioning_state: Provisioning state. Possible values include: - 'created' - :type provisioning_state: str or - ~azure.mgmt.apimanagement.models.ProvisioningState + :ivar provisioning_state: Provisioning state. Default value: "created". + :vartype provisioning_state: str """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'provisioning_state': {'constant': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'ProvisioningState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, } - def __init__(self, *, provisioning_state=None, **kwargs) -> None: + provisioning_state = "created" + + def __init__( + self, + **kwargs + ): super(AssociationContract, self).__init__(**kwargs) - self.provisioning_state = provisioning_state -class AuthenticationSettingsContract(Model): +class AuthenticationSettingsContract(msrest.serialization.Model): """API Authentication Settings. - :param o_auth2: OAuth2 Authentication settings - :type o_auth2: - ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract - :param openid: OpenID Connect Authentication Settings - :type openid: - ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract + :param o_auth2: OAuth2 Authentication settings. + :type o_auth2: ~azure.mgmt.apimanagement.models.OAuth2AuthenticationSettingsContract + :param openid: OpenID Connect Authentication Settings. + :type openid: ~azure.mgmt.apimanagement.models.OpenIdAuthenticationSettingsContract """ _attribute_map = { @@ -2171,19 +3145,53 @@ class AuthenticationSettingsContract(Model): 'openid': {'key': 'openid', 'type': 'OpenIdAuthenticationSettingsContract'}, } - def __init__(self, *, o_auth2=None, openid=None, **kwargs) -> None: + def __init__( + self, + *, + o_auth2: Optional["OAuth2AuthenticationSettingsContract"] = None, + openid: Optional["OpenIdAuthenticationSettingsContract"] = None, + **kwargs + ): super(AuthenticationSettingsContract, self).__init__(**kwargs) self.o_auth2 = o_auth2 self.openid = openid +class AuthorizationServerCollection(msrest.serialization.Model): + """Paged OAuth2 Authorization Servers list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.AuthorizationServerContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AuthorizationServerContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AuthorizationServerContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(AuthorizationServerCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + class AuthorizationServerContract(Resource): """External OAuth authorization server settings. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2191,67 +3199,58 @@ class AuthorizationServerContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str - :param display_name: Required. User-friendly authorization server name. + :param display_name: User-friendly authorization server name. :type display_name: str - :param client_registration_endpoint: Required. Optional reference to a - page where client or app registration for this authorization server is - performed. Contains absolute URL to entity being referenced. + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. :type client_registration_endpoint: str - :param authorization_endpoint: Required. OAuth authorization endpoint. See + :param authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. :type authorization_endpoint: str - :param grant_types: Required. Form of an authorization grant, which the - client uses to request the access token. + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Required. Client or app id registered with this - authorization server. + :param client_id: Client or app id registered with this authorization server. :type client_id: str - :param client_secret: Client or app secret registered with this - authorization server. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. :type client_secret: str """ @@ -2259,11 +3258,7 @@ class AuthorizationServerContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 50, 'min_length': 1}, - 'client_registration_endpoint': {'required': True}, - 'authorization_endpoint': {'required': True}, - 'grant_types': {'required': True}, - 'client_id': {'required': True}, + 'display_name': {'max_length': 50, 'min_length': 1}, } _attribute_map = { @@ -2271,7 +3266,7 @@ class AuthorizationServerContract(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, @@ -2288,7 +3283,27 @@ class AuthorizationServerContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, display_name: str, client_registration_endpoint: str, authorization_endpoint: str, grant_types, client_id: str, description: str=None, authorization_methods=None, client_authentication_method=None, token_body_parameters=None, token_endpoint: str=None, support_state: bool=None, default_scope: str=None, bearer_token_sending_methods=None, resource_owner_username: str=None, resource_owner_password: str=None, client_secret: str=None, **kwargs) -> None: + 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, + 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, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + display_name: Optional[str] = None, + client_registration_endpoint: Optional[str] = None, + authorization_endpoint: Optional[str] = None, + grant_types: Optional[List[Union[str, "GrantType"]]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(AuthorizationServerContract, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -2308,57 +3323,49 @@ def __init__(self, *, display_name: str, client_registration_endpoint: str, auth self.client_secret = client_secret -class AuthorizationServerContractBaseProperties(Model): +class AuthorizationServerContractBaseProperties(msrest.serialization.Model): """External OAuth authorization server Update settings contract. - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str """ _attribute_map = { 'description': {'key': 'description', 'type': 'str'}, - 'authorization_methods': {'key': 'authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, @@ -2369,7 +3376,21 @@ class AuthorizationServerContractBaseProperties(Model): 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, } - def __init__(self, *, description: str=None, authorization_methods=None, client_authentication_method=None, token_body_parameters=None, token_endpoint: str=None, support_state: bool=None, default_scope: str=None, bearer_token_sending_methods=None, resource_owner_username: str=None, resource_owner_password: str=None, **kwargs) -> None: + 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, + 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, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + **kwargs + ): super(AuthorizationServerContractBaseProperties, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -2383,11 +3404,160 @@ def __init__(self, *, description: str=None, authorization_methods=None, client_ self.resource_owner_password = resource_owner_password +class AuthorizationServerContractProperties(AuthorizationServerContractBaseProperties): + """External OAuth authorization server settings Properties. + + All required parameters must be populated in order to send to Azure. + + :param description: Description of the authorization server. Can contain HTML formatting tags. + :type description: str + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :type client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :type token_endpoint: str + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :type support_state: bool + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. + :type default_scope: str + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :type bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + :param display_name: Required. User-friendly authorization server name. + :type display_name: str + :param client_registration_endpoint: Required. Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :type client_registration_endpoint: str + :param authorization_endpoint: Required. OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :type authorization_endpoint: str + :param grant_types: Required. Form of an authorization grant, which the client uses to request + the access token. + :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :param client_id: Required. Client or app id registered with this authorization server. + :type client_id: str + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :type client_secret: str + """ + + _validation = { + 'display_name': {'required': True, 'max_length': 50, 'min_length': 1}, + 'client_registration_endpoint': {'required': True}, + 'authorization_endpoint': {'required': True}, + 'grant_types': {'required': True}, + 'client_id': {'required': True}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, + 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, + 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, + 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, + 'support_state': {'key': 'supportState', 'type': 'bool'}, + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, + 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, + 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: str, + client_registration_endpoint: str, + authorization_endpoint: str, + grant_types: List[Union[str, "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, + 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, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): + super(AuthorizationServerContractProperties, self).__init__(description=description, authorization_methods=authorization_methods, client_authentication_method=client_authentication_method, token_body_parameters=token_body_parameters, token_endpoint=token_endpoint, support_state=support_state, default_scope=default_scope, bearer_token_sending_methods=bearer_token_sending_methods, resource_owner_username=resource_owner_username, resource_owner_password=resource_owner_password, **kwargs) + self.display_name = display_name + self.client_registration_endpoint = client_registration_endpoint + self.authorization_endpoint = authorization_endpoint + self.grant_types = grant_types + self.client_id = client_id + self.client_secret = client_secret + + +class AuthorizationServerSecretsContract(msrest.serialization.Model): + """OAuth Server Secrets Contract. + + :param client_secret: oAuth Authorization Server Secrets. + :type client_secret: str + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + """ + + _attribute_map = { + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + } + + def __init__( + self, + *, + client_secret: Optional[str] = None, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + **kwargs + ): + super(AuthorizationServerSecretsContract, self).__init__(**kwargs) + self.client_secret = client_secret + self.resource_owner_username = resource_owner_username + self.resource_owner_password = resource_owner_password + + class AuthorizationServerUpdateContract(Resource): """External OAuth authorization server settings. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2395,67 +3565,58 @@ class AuthorizationServerUpdateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Description of the authorization server. Can contain - HTML formatting tags. + :param description: Description of the authorization server. Can contain HTML formatting tags. :type description: str - :param authorization_methods: HTTP verbs supported by the authorization - endpoint. GET must be always present. POST is optional. - :type authorization_methods: list[str or - ~azure.mgmt.apimanagement.models.AuthorizationMethod] - :param client_authentication_method: Method of authentication supported by - the token endpoint of this authorization server. Possible values are Basic - and/or Body. When Body is specified, client credentials and other - parameters are passed within the request body in the + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the application/x-www-form-urlencoded format. :type client_authentication_method: list[str or ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] - :param token_body_parameters: Additional parameters required by the token - endpoint of this authorization server represented as an array of JSON - objects with name and value string properties, i.e. {"name" : "name - value", "value": "a value"}. - :type token_body_parameters: - list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] - :param token_endpoint: OAuth token endpoint. Contains absolute URI to - entity being referenced. + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. :type token_endpoint: str - :param support_state: If true, authorization server will include state - parameter from the authorization request to its response. Client may use - state parameter to raise protocol security. + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. :type support_state: bool - :param default_scope: Access token scope that is going to be requested by - default. Can be overridden at the API level. Should be provided in the - form of a string containing space-delimited values. + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. :type default_scope: str - :param bearer_token_sending_methods: Specifies the mechanism by which - access token is passed to the API. + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. :type bearer_token_sending_methods: list[str or ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] - :param resource_owner_username: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner username. + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. :type resource_owner_username: str - :param resource_owner_password: Can be optionally specified when resource - owner password grant type is supported by this authorization server. - Default resource owner password. + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. :type resource_owner_password: str :param display_name: User-friendly authorization server name. :type display_name: str - :param client_registration_endpoint: Optional reference to a page where - client or app registration for this authorization server is performed. - Contains absolute URL to entity being referenced. + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. :type client_registration_endpoint: str :param authorization_endpoint: OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. :type authorization_endpoint: str - :param grant_types: Form of an authorization grant, which the client uses - to request the access token. + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] - :param client_id: Client or app id registered with this authorization - server. + :param client_id: Client or app id registered with this authorization server. :type client_id: str - :param client_secret: Client or app secret registered with this - authorization server. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. :type client_secret: str """ @@ -2471,7 +3632,7 @@ class AuthorizationServerUpdateContract(Resource): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[AuthorizationMethod]'}, + 'authorization_methods': {'key': 'properties.authorizationMethods', 'type': '[str]'}, 'client_authentication_method': {'key': 'properties.clientAuthenticationMethod', 'type': '[str]'}, 'token_body_parameters': {'key': 'properties.tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, 'token_endpoint': {'key': 'properties.tokenEndpoint', 'type': 'str'}, @@ -2488,7 +3649,27 @@ class AuthorizationServerUpdateContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, description: str=None, authorization_methods=None, client_authentication_method=None, token_body_parameters=None, token_endpoint: str=None, support_state: bool=None, default_scope: str=None, bearer_token_sending_methods=None, resource_owner_username: str=None, resource_owner_password: str=None, display_name: str=None, client_registration_endpoint: str=None, authorization_endpoint: str=None, grant_types=None, client_id: str=None, client_secret: str=None, **kwargs) -> None: + 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, + 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, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + display_name: Optional[str] = None, + client_registration_endpoint: Optional[str] = None, + authorization_endpoint: Optional[str] = None, + grant_types: Optional[List[Union[str, "GrantType"]]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(AuthorizationServerUpdateContract, self).__init__(**kwargs) self.description = description self.authorization_methods = authorization_methods @@ -2508,7 +3689,118 @@ def __init__(self, *, description: str=None, authorization_methods=None, client_ self.client_secret = client_secret -class BackendAuthorizationHeaderCredentials(Model): +class AuthorizationServerUpdateContractProperties(AuthorizationServerContractBaseProperties): + """External OAuth authorization server Update settings contract. + + :param description: Description of the authorization server. Can contain HTML formatting tags. + :type description: str + :param authorization_methods: HTTP verbs supported by the authorization endpoint. GET must be + always present. POST is optional. + :type authorization_methods: list[str or ~azure.mgmt.apimanagement.models.AuthorizationMethod] + :param client_authentication_method: Method of authentication supported by the token endpoint + of this authorization server. Possible values are Basic and/or Body. When Body is specified, + client credentials and other parameters are passed within the request body in the + application/x-www-form-urlencoded format. + :type client_authentication_method: list[str or + ~azure.mgmt.apimanagement.models.ClientAuthenticationMethod] + :param token_body_parameters: Additional parameters required by the token endpoint of this + authorization server represented as an array of JSON objects with name and value string + properties, i.e. {"name" : "name value", "value": "a value"}. + :type token_body_parameters: list[~azure.mgmt.apimanagement.models.TokenBodyParameterContract] + :param token_endpoint: OAuth token endpoint. Contains absolute URI to entity being referenced. + :type token_endpoint: str + :param support_state: If true, authorization server will include state parameter from the + authorization request to its response. Client may use state parameter to raise protocol + security. + :type support_state: bool + :param default_scope: Access token scope that is going to be requested by default. Can be + overridden at the API level. Should be provided in the form of a string containing space- + delimited values. + :type default_scope: str + :param bearer_token_sending_methods: Specifies the mechanism by which access token is passed to + the API. + :type bearer_token_sending_methods: list[str or + ~azure.mgmt.apimanagement.models.BearerTokenSendingMethod] + :param resource_owner_username: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner username. + :type resource_owner_username: str + :param resource_owner_password: Can be optionally specified when resource owner password grant + type is supported by this authorization server. Default resource owner password. + :type resource_owner_password: str + :param display_name: User-friendly authorization server name. + :type display_name: str + :param client_registration_endpoint: Optional reference to a page where client or app + registration for this authorization server is performed. Contains absolute URL to entity being + referenced. + :type client_registration_endpoint: str + :param authorization_endpoint: OAuth authorization endpoint. See + http://tools.ietf.org/html/rfc6749#section-3.2. + :type authorization_endpoint: str + :param grant_types: Form of an authorization grant, which the client uses to request the access + token. + :type grant_types: list[str or ~azure.mgmt.apimanagement.models.GrantType] + :param client_id: Client or app id registered with this authorization server. + :type client_id: str + :param client_secret: Client or app secret registered with this authorization server. This + property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the + value. + :type client_secret: str + """ + + _validation = { + 'display_name': {'max_length': 50, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'authorization_methods': {'key': 'authorizationMethods', 'type': '[str]'}, + 'client_authentication_method': {'key': 'clientAuthenticationMethod', 'type': '[str]'}, + 'token_body_parameters': {'key': 'tokenBodyParameters', 'type': '[TokenBodyParameterContract]'}, + 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, + 'support_state': {'key': 'supportState', 'type': 'bool'}, + 'default_scope': {'key': 'defaultScope', 'type': 'str'}, + 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, + 'resource_owner_username': {'key': 'resourceOwnerUsername', 'type': 'str'}, + 'resource_owner_password': {'key': 'resourceOwnerPassword', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'client_registration_endpoint': {'key': 'clientRegistrationEndpoint', 'type': 'str'}, + 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, + 'grant_types': {'key': 'grantTypes', 'type': '[str]'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + *, + 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, + 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, + resource_owner_username: Optional[str] = None, + resource_owner_password: Optional[str] = None, + display_name: Optional[str] = None, + client_registration_endpoint: Optional[str] = None, + authorization_endpoint: Optional[str] = None, + grant_types: Optional[List[Union[str, "GrantType"]]] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): + super(AuthorizationServerUpdateContractProperties, self).__init__(description=description, authorization_methods=authorization_methods, client_authentication_method=client_authentication_method, token_body_parameters=token_body_parameters, token_endpoint=token_endpoint, support_state=support_state, default_scope=default_scope, bearer_token_sending_methods=bearer_token_sending_methods, resource_owner_username=resource_owner_username, resource_owner_password=resource_owner_password, **kwargs) + self.display_name = display_name + self.client_registration_endpoint = client_registration_endpoint + self.authorization_endpoint = authorization_endpoint + self.grant_types = grant_types + self.client_id = client_id + self.client_secret = client_secret + + +class BackendAuthorizationHeaderCredentials(msrest.serialization.Model): """Authorization header information. All required parameters must be populated in order to send to Azure. @@ -2529,31 +3821,35 @@ class BackendAuthorizationHeaderCredentials(Model): 'parameter': {'key': 'parameter', 'type': 'str'}, } - def __init__(self, *, scheme: str, parameter: str, **kwargs) -> None: + def __init__( + self, + *, + scheme: str, + parameter: str, + **kwargs + ): super(BackendAuthorizationHeaderCredentials, self).__init__(**kwargs) self.scheme = scheme self.parameter = parameter -class BackendBaseParameters(Model): +class BackendBaseParameters(msrest.serialization.Model): """Backend entity base Parameter set. :param title: Backend Title. :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties """ @@ -2573,7 +3869,18 @@ class BackendBaseParameters(Model): 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, } - def __init__(self, *, title: str=None, description: str=None, resource_id: str=None, properties=None, credentials=None, proxy=None, tls=None, **kwargs) -> None: + def __init__( + self, + *, + 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, + **kwargs + ): super(BackendBaseParameters, self).__init__(**kwargs) self.title = title self.description = description @@ -2584,13 +3891,36 @@ def __init__(self, *, title: str=None, description: str=None, resource_id: str=N self.tls = tls +class BackendCollection(msrest.serialization.Model): + """Paged Backend list representation. + + :param value: Backend values. + :type value: list[~azure.mgmt.apimanagement.models.BackendContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BackendContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["BackendContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(BackendCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class BackendContract(Resource): """Backend details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2602,23 +3932,20 @@ class BackendContract(Resource): :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties - :param url: Required. Runtime Url of the Backend. + :param url: Runtime Url of the Backend. :type url: str - :param protocol: Required. Backend communication protocol. Possible values - include: 'http', 'soap' + :param protocol: Backend communication protocol. Possible values include: "http", "soap". :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ @@ -2629,8 +3956,7 @@ class BackendContract(Resource): 'title': {'max_length': 300, 'min_length': 1}, 'description': {'max_length': 2000, 'min_length': 1}, 'resource_id': {'max_length': 2000, 'min_length': 1}, - 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, - 'protocol': {'required': True}, + 'url': {'max_length': 2000, 'min_length': 1}, } _attribute_map = { @@ -2648,7 +3974,20 @@ class BackendContract(Resource): 'protocol': {'key': 'properties.protocol', 'type': 'str'}, } - def __init__(self, *, url: str, protocol, title: str=None, description: str=None, resource_id: str=None, properties=None, credentials=None, proxy=None, tls=None, **kwargs) -> None: + def __init__( + self, + *, + 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, + url: Optional[str] = None, + protocol: Optional[Union[str, "BackendProtocol"]] = None, + **kwargs + ): super(BackendContract, self).__init__(**kwargs) self.title = title self.description = description @@ -2661,7 +4000,73 @@ def __init__(self, *, url: str, protocol, title: str=None, description: str=None self.protocol = protocol -class BackendCredentialsContract(Model): +class BackendContractProperties(BackendBaseParameters): + """Parameters supplied to the Create Backend operation. + + All required parameters must be populated in order to send to Azure. + + :param title: Backend Title. + :type title: str + :param description: Backend Description. + :type description: str + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. + :type resource_id: str + :param properties: Backend Properties contract. + :type properties: ~azure.mgmt.apimanagement.models.BackendProperties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. + :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :param tls: Backend TLS Properties. + :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :param url: Required. Runtime Url of the Backend. + :type url: str + :param protocol: Required. Backend communication protocol. Possible values include: "http", + "soap". + :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + _validation = { + 'title': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 2000, 'min_length': 1}, + 'resource_id': {'max_length': 2000, 'min_length': 1}, + 'url': {'required': True, 'max_length': 2000, 'min_length': 1}, + 'protocol': {'required': True}, + } + + _attribute_map = { + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BackendProperties'}, + 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, + 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, + 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, + 'url': {'key': 'url', 'type': 'str'}, + 'protocol': {'key': 'protocol', 'type': 'str'}, + } + + def __init__( + self, + *, + url: str, + protocol: Union[str, "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, + **kwargs + ): + super(BackendContractProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) + self.url = url + self.protocol = protocol + + +class BackendCredentialsContract(msrest.serialization.Model): """Details of the Credentials used to connect to Backend. :param certificate: List of Client Certificate Thumbprint. @@ -2670,13 +4075,12 @@ class BackendCredentialsContract(Model): :type query: dict[str, list[str]] :param header: Header Parameter description. :type header: dict[str, list[str]] - :param authorization: Authorization header authentication - :type authorization: - ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials + :param authorization: Authorization header authentication. + :type authorization: ~azure.mgmt.apimanagement.models.BackendAuthorizationHeaderCredentials """ _validation = { - 'certificate': {'max_items': 32}, + 'certificate': {'max_items': 32, 'min_items': 0}, } _attribute_map = { @@ -2686,7 +4090,15 @@ class BackendCredentialsContract(Model): 'authorization': {'key': 'authorization', 'type': 'BackendAuthorizationHeaderCredentials'}, } - def __init__(self, *, certificate=None, query=None, header=None, authorization=None, **kwargs) -> None: + def __init__( + self, + *, + certificate: Optional[List[str]] = None, + query: Optional[Dict[str, List[str]]] = None, + header: Optional[Dict[str, List[str]]] = None, + authorization: Optional["BackendAuthorizationHeaderCredentials"] = None, + **kwargs + ): super(BackendCredentialsContract, self).__init__(**kwargs) self.certificate = certificate self.query = query @@ -2694,10 +4106,10 @@ def __init__(self, *, certificate=None, query=None, header=None, authorization=N self.authorization = authorization -class BackendProperties(Model): +class BackendProperties(msrest.serialization.Model): """Properties specific to the Backend Type. - :param service_fabric_cluster: Backend Service Fabric Cluster Properties + :param service_fabric_cluster: Backend Service Fabric Cluster Properties. :type service_fabric_cluster: ~azure.mgmt.apimanagement.models.BackendServiceFabricClusterProperties """ @@ -2706,23 +4118,27 @@ class BackendProperties(Model): 'service_fabric_cluster': {'key': 'serviceFabricCluster', 'type': 'BackendServiceFabricClusterProperties'}, } - def __init__(self, *, service_fabric_cluster=None, **kwargs) -> None: + def __init__( + self, + *, + service_fabric_cluster: Optional["BackendServiceFabricClusterProperties"] = None, + **kwargs + ): super(BackendProperties, self).__init__(**kwargs) self.service_fabric_cluster = service_fabric_cluster -class BackendProxyContract(Model): +class BackendProxyContract(msrest.serialization.Model): """Details of the Backend WebProxy Server to use in the Request to Backend. All required parameters must be populated in order to send to Azure. - :param url: Required. WebProxy Server AbsoluteUri property which includes - the entire URI stored in the Uri instance, including all fragments and - query strings. + :param url: Required. WebProxy Server AbsoluteUri property which includes the entire URI stored + in the Uri instance, including all fragments and query strings. :type url: str - :param username: Username to connect to the WebProxy server + :param username: Username to connect to the WebProxy server. :type username: str - :param password: Password to connect to the WebProxy Server + :param password: Password to connect to the WebProxy Server. :type password: str """ @@ -2736,7 +4152,14 @@ class BackendProxyContract(Model): 'password': {'key': 'password', 'type': 'str'}, } - def __init__(self, *, url: str, username: str=None, password: str=None, **kwargs) -> None: + def __init__( + self, + *, + url: str, + username: Optional[str] = None, + password: Optional[str] = None, + **kwargs + ): super(BackendProxyContract, self).__init__(**kwargs) self.url = url self.username = username @@ -2746,8 +4169,7 @@ def __init__(self, *, url: str, username: str=None, password: str=None, **kwargs class BackendReconnectContract(Resource): """Reconnect request parameters. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2755,9 +4177,9 @@ class BackendReconnectContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param after: Duration in ISO8601 format after which reconnect will be - initiated. Minimum duration of the Reconnect is PT2M. - :type after: timedelta + :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + duration of the Reconnect is PT2M. + :type after: ~datetime.timedelta """ _validation = { @@ -2773,30 +4195,34 @@ class BackendReconnectContract(Resource): 'after': {'key': 'properties.after', 'type': 'duration'}, } - def __init__(self, *, after=None, **kwargs) -> None: + def __init__( + self, + *, + after: Optional[datetime.timedelta] = None, + **kwargs + ): super(BackendReconnectContract, self).__init__(**kwargs) self.after = after -class BackendServiceFabricClusterProperties(Model): +class BackendServiceFabricClusterProperties(msrest.serialization.Model): """Properties of the Service Fabric Type Backend. All required parameters must be populated in order to send to Azure. - :param client_certificatethumbprint: Required. The client certificate - thumbprint for the management endpoint. + :param client_certificatethumbprint: Required. The client certificate thumbprint for the + management endpoint. :type client_certificatethumbprint: str - :param max_partition_resolution_retries: Maximum number of retries while - attempting resolve the partition. + :param max_partition_resolution_retries: Maximum number of retries while attempting resolve the + partition. :type max_partition_resolution_retries: int :param management_endpoints: Required. The cluster management endpoint. :type management_endpoints: list[str] - :param server_certificate_thumbprints: Thumbprints of certificates cluster - management service uses for tls communication + :param server_certificate_thumbprints: Thumbprints of certificates cluster management service + uses for tls communication. :type server_certificate_thumbprints: list[str] - :param server_x509_names: Server X509 Certificate Names Collection - :type server_x509_names: - list[~azure.mgmt.apimanagement.models.X509CertificateName] + :param server_x509_names: Server X509 Certificate Names Collection. + :type server_x509_names: list[~azure.mgmt.apimanagement.models.X509CertificateName] """ _validation = { @@ -2812,7 +4238,16 @@ class BackendServiceFabricClusterProperties(Model): 'server_x509_names': {'key': 'serverX509Names', 'type': '[X509CertificateName]'}, } - def __init__(self, *, client_certificatethumbprint: str, management_endpoints, max_partition_resolution_retries: int=None, server_certificate_thumbprints=None, server_x509_names=None, **kwargs) -> None: + def __init__( + self, + *, + client_certificatethumbprint: str, + management_endpoints: List[str], + max_partition_resolution_retries: Optional[int] = None, + server_certificate_thumbprints: Optional[List[str]] = None, + server_x509_names: Optional[List["X509CertificateName"]] = None, + **kwargs + ): super(BackendServiceFabricClusterProperties, self).__init__(**kwargs) self.client_certificatethumbprint = client_certificatethumbprint self.max_partition_resolution_retries = max_partition_resolution_retries @@ -2821,16 +4256,14 @@ def __init__(self, *, client_certificatethumbprint: str, management_endpoints, m self.server_x509_names = server_x509_names -class BackendTlsProperties(Model): +class BackendTlsProperties(msrest.serialization.Model): """Properties controlling TLS Certificate Validation. - :param validate_certificate_chain: Flag indicating whether SSL certificate - chain validation should be done when using self-signed certificates for - this backend host. Default value: True . + :param validate_certificate_chain: Flag indicating whether SSL certificate chain validation + should be done when using self-signed certificates for this backend host. :type validate_certificate_chain: bool - :param validate_certificate_name: Flag indicating whether SSL certificate - name validation should be done when using self-signed certificates for - this backend host. Default value: True . + :param validate_certificate_name: Flag indicating whether SSL certificate name validation + should be done when using self-signed certificates for this backend host. :type validate_certificate_name: bool """ @@ -2839,36 +4272,101 @@ class BackendTlsProperties(Model): 'validate_certificate_name': {'key': 'validateCertificateName', 'type': 'bool'}, } - def __init__(self, *, validate_certificate_chain: bool=True, validate_certificate_name: bool=True, **kwargs) -> None: + def __init__( + self, + *, + validate_certificate_chain: Optional[bool] = True, + validate_certificate_name: Optional[bool] = True, + **kwargs + ): super(BackendTlsProperties, self).__init__(**kwargs) self.validate_certificate_chain = validate_certificate_chain self.validate_certificate_name = validate_certificate_name -class BackendUpdateParameters(Model): +class BackendUpdateParameterProperties(BackendBaseParameters): + """Parameters supplied to the Update Backend operation. + + :param title: Backend Title. + :type title: str + :param description: Backend Description. + :type description: str + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. + :type resource_id: str + :param properties: Backend Properties contract. + :type properties: ~azure.mgmt.apimanagement.models.BackendProperties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. + :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract + :param tls: Backend TLS Properties. + :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties + :param url: Runtime Url of the Backend. + :type url: str + :param protocol: Backend communication protocol. Possible values include: "http", "soap". + :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol + """ + + _validation = { + 'title': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 2000, 'min_length': 1}, + 'resource_id': {'max_length': 2000, 'min_length': 1}, + 'url': {'max_length': 2000, 'min_length': 1}, + } + + _attribute_map = { + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'BackendProperties'}, + 'credentials': {'key': 'credentials', 'type': 'BackendCredentialsContract'}, + 'proxy': {'key': 'proxy', 'type': 'BackendProxyContract'}, + 'tls': {'key': 'tls', 'type': 'BackendTlsProperties'}, + 'url': {'key': 'url', 'type': 'str'}, + 'protocol': {'key': 'protocol', 'type': 'str'}, + } + + def __init__( + self, + *, + 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, + url: Optional[str] = None, + protocol: Optional[Union[str, "BackendProtocol"]] = None, + **kwargs + ): + super(BackendUpdateParameterProperties, self).__init__(title=title, description=description, resource_id=resource_id, properties=properties, credentials=credentials, proxy=proxy, tls=tls, **kwargs) + self.url = url + self.protocol = protocol + + +class BackendUpdateParameters(msrest.serialization.Model): """Backend update parameters. :param title: Backend Title. :type title: str :param description: Backend Description. :type description: str - :param resource_id: Management Uri of the Resource in External System. - This url can be the Arm Resource Id of Logic Apps, Function Apps or Api - Apps. + :param resource_id: Management Uri of the Resource in External System. This url can be the Arm + Resource Id of Logic Apps, Function Apps or Api Apps. :type resource_id: str - :param properties: Backend Properties contract + :param properties: Backend Properties contract. :type properties: ~azure.mgmt.apimanagement.models.BackendProperties - :param credentials: Backend Credentials Contract Properties - :type credentials: - ~azure.mgmt.apimanagement.models.BackendCredentialsContract - :param proxy: Backend Proxy Contract Properties + :param credentials: Backend Credentials Contract Properties. + :type credentials: ~azure.mgmt.apimanagement.models.BackendCredentialsContract + :param proxy: Backend Proxy Contract Properties. :type proxy: ~azure.mgmt.apimanagement.models.BackendProxyContract - :param tls: Backend TLS Properties + :param tls: Backend TLS Properties. :type tls: ~azure.mgmt.apimanagement.models.BackendTlsProperties :param url: Runtime Url of the Backend. :type url: str - :param protocol: Backend communication protocol. Possible values include: - 'http', 'soap' + :param protocol: Backend communication protocol. Possible values include: "http", "soap". :type protocol: str or ~azure.mgmt.apimanagement.models.BackendProtocol """ @@ -2891,7 +4389,20 @@ class BackendUpdateParameters(Model): 'protocol': {'key': 'properties.protocol', 'type': 'str'}, } - def __init__(self, *, title: str=None, description: str=None, resource_id: str=None, properties=None, credentials=None, proxy=None, tls=None, url: str=None, protocol=None, **kwargs) -> None: + def __init__( + self, + *, + 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, + url: Optional[str] = None, + protocol: Optional[Union[str, "BackendProtocol"]] = None, + **kwargs + ): super(BackendUpdateParameters, self).__init__(**kwargs) self.title = title self.description = description @@ -2904,7 +4415,7 @@ def __init__(self, *, title: str=None, description: str=None, resource_id: str=N self.protocol = protocol -class BodyDiagnosticSettings(Model): +class BodyDiagnosticSettings(msrest.serialization.Model): """Body logging settings. :param bytes: Number of request body bytes to log. @@ -2919,18 +4430,46 @@ class BodyDiagnosticSettings(Model): 'bytes': {'key': 'bytes', 'type': 'int'}, } - def __init__(self, *, bytes: int=None, **kwargs) -> None: + def __init__( + self, + *, + bytes: Optional[int] = None, + **kwargs + ): super(BodyDiagnosticSettings, self).__init__(**kwargs) self.bytes = bytes +class CacheCollection(msrest.serialization.Model): + """Paged Caches list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.CacheContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CacheContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CacheContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(CacheCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class CacheContract(Resource): """Cache details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -2938,12 +4477,14 @@ class CacheContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param description: Cache description + :param description: Cache description. :type description: str - :param connection_string: Required. Runtime connection string to cache + :param connection_string: Runtime connection string to cache. :type connection_string: str - :param resource_id: Original uri of entity in external system cache points - to + :param use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). + :type use_from_location: str + :param resource_id: Original uri of entity in external system cache points to. :type resource_id: str """ @@ -2951,9 +4492,10 @@ class CacheContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 2000}, - 'connection_string': {'required': True, 'max_length': 300}, - 'resource_id': {'max_length': 2000}, + 'description': {'max_length': 2000, 'min_length': 0}, + 'connection_string': {'max_length': 300, 'min_length': 0}, + 'use_from_location': {'max_length': 256, 'min_length': 0}, + 'resource_id': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { @@ -2962,62 +4504,109 @@ class CacheContract(Resource): 'type': {'key': 'type', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, + 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, *, connection_string: str, description: str=None, resource_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + connection_string: Optional[str] = None, + use_from_location: Optional[str] = None, + resource_id: Optional[str] = None, + **kwargs + ): super(CacheContract, self).__init__(**kwargs) self.description = description self.connection_string = connection_string + self.use_from_location = use_from_location self.resource_id = resource_id -class CacheUpdateParameters(Model): +class CacheUpdateParameters(msrest.serialization.Model): """Cache update details. - :param description: Cache description + :param description: Cache description. :type description: str - :param connection_string: Runtime connection string to cache + :param connection_string: Runtime connection string to cache. :type connection_string: str - :param resource_id: Original uri of entity in external system cache points - to + :param use_from_location: Location identifier to use cache from (should be either 'default' or + valid Azure region identifier). + :type use_from_location: str + :param resource_id: Original uri of entity in external system cache points to. :type resource_id: str """ _validation = { - 'description': {'max_length': 2000}, - 'connection_string': {'max_length': 300}, - 'resource_id': {'max_length': 2000}, + 'description': {'max_length': 2000, 'min_length': 0}, + 'connection_string': {'max_length': 300, 'min_length': 0}, + 'use_from_location': {'max_length': 256, 'min_length': 0}, + 'resource_id': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { 'description': {'key': 'properties.description', 'type': 'str'}, 'connection_string': {'key': 'properties.connectionString', 'type': 'str'}, + 'use_from_location': {'key': 'properties.useFromLocation', 'type': 'str'}, 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, *, description: str=None, connection_string: str=None, resource_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + connection_string: Optional[str] = None, + use_from_location: Optional[str] = None, + resource_id: Optional[str] = None, + **kwargs + ): super(CacheUpdateParameters, self).__init__(**kwargs) self.description = description self.connection_string = connection_string + self.use_from_location = use_from_location self.resource_id = resource_id -class CertificateConfiguration(Model): - """Certificate configuration which consist of non-trusted intermediates and - root certificates. +class CertificateCollection(msrest.serialization.Model): + """Paged Certificates list representation. - All required parameters must be populated in order to send to Azure. + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.CertificateContract] + :param next_link: Next page link if any. + :type next_link: str + """ - :param encoded_certificate: Base64 Encoded certificate. - :type encoded_certificate: str + _attribute_map = { + 'value': {'key': 'value', 'type': '[CertificateContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CertificateContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(CertificateCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CertificateConfiguration(msrest.serialization.Model): + """Certificate configuration which consist of non-trusted intermediates and root certificates. + + All required parameters must be populated in order to send to Azure. + + :param encoded_certificate: Base64 Encoded certificate. + :type encoded_certificate: str :param certificate_password: Certificate Password. :type certificate_password: str - :param store_name: Required. The - System.Security.Cryptography.x509certificates.StoreName certificate store - location. Only Root and CertificateAuthority are valid locations. Possible - values include: 'CertificateAuthority', 'Root' - :type store_name: str or ~azure.mgmt.apimanagement.models.enum + :param store_name: Required. The System.Security.Cryptography.x509certificates.StoreName + certificate store location. Only Root and CertificateAuthority are valid locations. Possible + values include: "CertificateAuthority", "Root". + :type store_name: str or ~azure.mgmt.apimanagement.models.CertificateConfigurationStoreName :param certificate: Certificate information. :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation """ @@ -3033,7 +4622,15 @@ class CertificateConfiguration(Model): 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, } - def __init__(self, *, store_name, encoded_certificate: str=None, certificate_password: str=None, certificate=None, **kwargs) -> None: + def __init__( + self, + *, + store_name: Union[str, "CertificateConfigurationStoreName"], + encoded_certificate: Optional[str] = None, + certificate_password: Optional[str] = None, + certificate: Optional["CertificateInformation"] = None, + **kwargs + ): super(CertificateConfiguration, self).__init__(**kwargs) self.encoded_certificate = encoded_certificate self.certificate_password = certificate_password @@ -3044,10 +4641,7 @@ def __init__(self, *, store_name, encoded_certificate: str=None, certificate_pas class CertificateContract(Resource): """Certificate details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3055,23 +4649,21 @@ class CertificateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param subject: Required. Subject attribute of the certificate. + :param subject: Subject attribute of the certificate. :type subject: str - :param thumbprint: Required. Thumbprint of the certificate. + :param thumbprint: Thumbprint of the certificate. :type thumbprint: str - :param expiration_date: Required. Expiration date of the certificate. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime + :param expiration_date: Expiration date of the certificate. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime + :param key_vault: KeyVault location details of the certificate. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'subject': {'required': True}, - 'thumbprint': {'required': True}, - 'expiration_date': {'required': True}, } _attribute_map = { @@ -3081,52 +4673,64 @@ class CertificateContract(Resource): 'subject': {'key': 'properties.subject', 'type': 'str'}, 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - } - - def __init__(self, *, subject: str, thumbprint: str, expiration_date, **kwargs) -> None: + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractProperties'}, + } + + def __init__( + self, + *, + subject: Optional[str] = None, + thumbprint: Optional[str] = None, + expiration_date: Optional[datetime.datetime] = None, + key_vault: Optional["KeyVaultContractProperties"] = None, + **kwargs + ): super(CertificateContract, self).__init__(**kwargs) self.subject = subject self.thumbprint = thumbprint self.expiration_date = expiration_date + self.key_vault = key_vault -class CertificateCreateOrUpdateParameters(Model): +class CertificateCreateOrUpdateParameters(msrest.serialization.Model): """Certificate create or update details. - All required parameters must be populated in order to send to Azure. - - :param data: Required. Base 64 encoded certificate using the - application/x-pkcs12 representation. + :param data: Base 64 encoded certificate using the application/x-pkcs12 representation. :type data: str - :param password: Required. Password for the Certificate + :param password: Password for the Certificate. :type password: str + :param key_vault: KeyVault location details of the certificate. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ - _validation = { - 'data': {'required': True}, - 'password': {'required': True}, - } - _attribute_map = { 'data': {'key': 'properties.data', 'type': 'str'}, 'password': {'key': 'properties.password', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, } - def __init__(self, *, data: str, password: str, **kwargs) -> None: + def __init__( + self, + *, + data: Optional[str] = None, + password: Optional[str] = None, + key_vault: Optional["KeyVaultContractCreateProperties"] = None, + **kwargs + ): super(CertificateCreateOrUpdateParameters, self).__init__(**kwargs) self.data = data self.password = password + self.key_vault = key_vault -class CertificateInformation(Model): +class CertificateInformation(msrest.serialization.Model): """SSL certificate information. All required parameters must be populated in order to send to Azure. - :param expiry: Required. Expiration date of the certificate. The date - conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by - the ISO 8601 standard. - :type expiry: datetime + :param expiry: Required. Expiration date of the certificate. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiry: ~datetime.datetime :param thumbprint: Required. Thumbprint of the certificate. :type thumbprint: str :param subject: Required. Subject of the certificate. @@ -3145,18 +4749,24 @@ class CertificateInformation(Model): 'subject': {'key': 'subject', 'type': 'str'}, } - def __init__(self, *, expiry, thumbprint: str, subject: str, **kwargs) -> None: + def __init__( + self, + *, + expiry: datetime.datetime, + thumbprint: str, + subject: str, + **kwargs + ): super(CertificateInformation, self).__init__(**kwargs) self.expiry = expiry self.thumbprint = thumbprint self.subject = subject -class ClientSecretContract(Model): +class ClientSecretContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param client_secret: Client or app secret used in IdentityProviders, Aad, - OpenID or OAuth. + :param client_secret: Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. :type client_secret: str """ @@ -3164,46 +4774,43 @@ class ClientSecretContract(Model): 'client_secret': {'key': 'clientSecret', 'type': 'str'}, } - def __init__(self, *, client_secret: str=None, **kwargs) -> None: + def __init__( + self, + *, + client_secret: Optional[str] = None, + **kwargs + ): super(ClientSecretContract, self).__init__(**kwargs) self.client_secret = client_secret -class CloudError(Model): - """CloudError. - """ - - _attribute_map = { - } - - -class ConnectivityStatusContract(Model): +class ConnectivityStatusContract(msrest.serialization.Model): """Details about connectivity to a resource. All required parameters must be populated in order to send to Azure. - :param name: Required. The hostname of the resource which the service - depends on. This can be the database, storage or any other azure resource - on which the service depends upon. + :param name: Required. The hostname of the resource which the service depends on. This can be + the database, storage or any other azure resource on which the service depends upon. :type name: str - :param status: Required. Resource Connectivity Status Type identifier. - Possible values include: 'initializing', 'success', 'failure' - :type status: str or - ~azure.mgmt.apimanagement.models.ConnectivityStatusType + :param status: Required. Resource Connectivity Status Type identifier. Possible values include: + "initializing", "success", "failure". + :type status: str or ~azure.mgmt.apimanagement.models.ConnectivityStatusType :param error: Error details of the connectivity to the resource. :type error: str - :param last_updated: Required. The date when the resource connectivity - status was last updated. This status should be updated every 15 minutes. - If this status has not been updated, then it means that the service has - lost network connectivity to the resource, from inside the Virtual - Network.The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type last_updated: datetime - :param last_status_change: Required. The date when the resource - connectivity status last Changed from success to failure or vice-versa. - The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as - specified by the ISO 8601 standard. - :type last_status_change: datetime + :param last_updated: Required. The date when the resource connectivity status was last updated. + This status should be updated every 15 minutes. If this status has not been updated, then it + means that the service has lost network connectivity to the resource, from inside the Virtual + Network.The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. + :type last_updated: ~datetime.datetime + :param last_status_change: Required. The date when the resource connectivity status last + Changed from success to failure or vice-versa. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type last_status_change: ~datetime.datetime + :param resource_type: Required. Resource Type. + :type resource_type: str + :param is_optional: Required. Whether this is optional. + :type is_optional: bool """ _validation = { @@ -3211,6 +4818,8 @@ class ConnectivityStatusContract(Model): 'status': {'required': True}, 'last_updated': {'required': True}, 'last_status_change': {'required': True}, + 'resource_type': {'required': True}, + 'is_optional': {'required': True}, } _attribute_map = { @@ -3219,52 +4828,384 @@ class ConnectivityStatusContract(Model): 'error': {'key': 'error', 'type': 'str'}, 'last_updated': {'key': 'lastUpdated', 'type': 'iso-8601'}, 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, - } - - def __init__(self, *, name: str, status, last_updated, last_status_change, error: str=None, **kwargs) -> None: + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'is_optional': {'key': 'isOptional', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + status: Union[str, "ConnectivityStatusType"], + last_updated: datetime.datetime, + last_status_change: datetime.datetime, + resource_type: str, + is_optional: bool, + error: Optional[str] = None, + **kwargs + ): super(ConnectivityStatusContract, self).__init__(**kwargs) self.name = name self.status = status self.error = error self.last_updated = last_updated self.last_status_change = last_status_change + self.resource_type = resource_type + self.is_optional = is_optional -class DeployConfigurationParameters(Model): - """Deploy Tenant Configuration Contract. +class ContentItemCollection(msrest.serialization.Model): + """Paged list of content items. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :param branch: Required. The name of the Git branch from which the - configuration is to be deployed to the configuration database. - :type branch: str - :param force: The value enforcing deleting subscriptions to products that - are deleted in this update. - :type force: bool + :ivar value: Collection of content items. + :vartype value: list[~azure.mgmt.apimanagement.models.ContentItemContract] + :ivar next_link: Next page link, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ContentItemContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentItemCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContentItemContract(Resource): + """Content type contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :param properties: Properties of the content item. + :type properties: dict[str, object] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{object}'}, + } + + def __init__( + self, + *, + properties: Optional[Dict[str, object]] = None, + **kwargs + ): + super(ContentItemContract, self).__init__(**kwargs) + self.properties = properties + + +class ContentTypeCollection(msrest.serialization.Model): + """Paged list of content types. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of content types. + :vartype value: list[~azure.mgmt.apimanagement.models.ContentTypeContract] + :ivar next_link: Next page link, if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ContentTypeContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContentTypeCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContentTypeContract(Resource): + """Content type contract details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :param id_properties_id: Content type identifier. + :type id_properties_id: str + :param name_properties_name: Content type name. Must be 1 to 250 characters long. + :type name_properties_name: str + :param description: Content type description. + :type description: str + :param schema: Content type schema. + :type schema: object + :param version: Content type version. + :type version: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'id_properties_id': {'key': 'properties.id', 'type': 'str'}, + 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'schema': {'key': 'properties.schema', 'type': 'object'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + } + + def __init__( + self, + *, + id_properties_id: Optional[str] = None, + name_properties_name: Optional[str] = None, + description: Optional[str] = None, + schema: Optional[object] = None, + version: Optional[str] = None, + **kwargs + ): + super(ContentTypeContract, self).__init__(**kwargs) + self.id_properties_id = id_properties_id + self.name_properties_name = name_properties_name + self.description = description + self.schema = schema + self.version = version + + +class DataMasking(msrest.serialization.Model): + """DataMasking. + + :param query_params: Masking settings for Url query parameters. + :type query_params: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + :param headers: Masking settings for headers. + :type headers: list[~azure.mgmt.apimanagement.models.DataMaskingEntity] + """ + + _attribute_map = { + 'query_params': {'key': 'queryParams', 'type': '[DataMaskingEntity]'}, + 'headers': {'key': 'headers', 'type': '[DataMaskingEntity]'}, + } + + def __init__( + self, + *, + query_params: Optional[List["DataMaskingEntity"]] = None, + headers: Optional[List["DataMaskingEntity"]] = None, + **kwargs + ): + super(DataMasking, self).__init__(**kwargs) + self.query_params = query_params + self.headers = headers + + +class DataMaskingEntity(msrest.serialization.Model): + """DataMaskingEntity. + + :param value: The name of an entity to mask (e.g. a name of a header or a query parameter). + :type value: str + :param mode: Data masking mode. Possible values include: "Mask", "Hide". + :type mode: str or ~azure.mgmt.apimanagement.models.DataMaskingMode + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'mode': {'key': 'mode', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + mode: Optional[Union[str, "DataMaskingMode"]] = None, + **kwargs + ): + super(DataMaskingEntity, self).__init__(**kwargs) + self.value = value + self.mode = mode + + +class DeletedServiceContract(Resource): + """Deleted Api Management Service information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type for API Management resource. + :vartype type: str + :ivar location: Api Management Service Master Location. + :vartype location: str + :param service_id: Fully-qualified API Management Service Resource ID. + :type service_id: str + :param scheduled_purge_date: UTC Date and Time when the service will be automatically purged. + The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + standard. + :type scheduled_purge_date: ~datetime.datetime + :param deletion_date: UTC Timestamp when the service was soft-deleted. The date conforms to the + following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :type deletion_date: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'service_id': {'key': 'properties.serviceId', 'type': 'str'}, + 'scheduled_purge_date': {'key': 'properties.scheduledPurgeDate', 'type': 'iso-8601'}, + 'deletion_date': {'key': 'properties.deletionDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + service_id: Optional[str] = None, + scheduled_purge_date: Optional[datetime.datetime] = None, + deletion_date: Optional[datetime.datetime] = None, + **kwargs + ): + super(DeletedServiceContract, self).__init__(**kwargs) + self.location = None + self.service_id = service_id + self.scheduled_purge_date = scheduled_purge_date + self.deletion_date = deletion_date + + +class DeletedServicesCollection(msrest.serialization.Model): + """Paged deleted Api Management Services List Representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.DeletedServiceContract] + :ivar next_link: Next page link if any. + :vartype next_link: str """ _validation = { - 'branch': {'required': True}, + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeletedServiceContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } + def __init__( + self, + **kwargs + ): + super(DeletedServicesCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class DeployConfigurationParameters(msrest.serialization.Model): + """Deploy Tenant Configuration Contract. + + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. + :type branch: str + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. + :type force: bool + """ + _attribute_map = { 'branch': {'key': 'properties.branch', 'type': 'str'}, 'force': {'key': 'properties.force', 'type': 'bool'}, } - def __init__(self, *, branch: str, force: bool=None, **kwargs) -> None: + def __init__( + self, + *, + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ): super(DeployConfigurationParameters, self).__init__(**kwargs) self.branch = branch self.force = force +class DiagnosticCollection(msrest.serialization.Model): + """Paged Diagnostic list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.DiagnosticContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DiagnosticContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["DiagnosticContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(DiagnosticCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class DiagnosticContract(Resource): """Diagnostic details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3272,37 +5213,35 @@ class DiagnosticContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param always_log: Specifies for what type of messages sampling settings - should not apply. Possible values include: 'allErrors' + :param always_log: Specifies for what type of messages sampling settings should not apply. + Possible values include: "allErrors". :type always_log: str or ~azure.mgmt.apimanagement.models.AlwaysLog - :param logger_id: Required. Resource Id of a target logger. + :param logger_id: Resource Id of a target logger. :type logger_id: str :param sampling: Sampling settings for Diagnostic. :type sampling: ~azure.mgmt.apimanagement.models.SamplingSettings - :param frontend: Diagnostic settings for incoming/outgoing HTTP messages - to the Gateway. - :type frontend: - ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings - :param backend: Diagnostic settings for incoming/outgoing HTTP messages to - the Backend + :param frontend: Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + :type frontend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings + :param backend: Diagnostic settings for incoming/outgoing HTTP messages to the Backend. :type backend: ~azure.mgmt.apimanagement.models.PipelineDiagnosticSettings :param log_client_ip: Log the ClientIP. Default is false. :type log_client_ip: bool - :param http_correlation_protocol: Sets correlation protocol to use for - Application Insights diagnostics. Possible values include: 'None', - 'Legacy', 'W3C' + :param http_correlation_protocol: Sets correlation protocol to use for Application Insights + diagnostics. Possible values include: "None", "Legacy", "W3C". :type http_correlation_protocol: str or ~azure.mgmt.apimanagement.models.HttpCorrelationProtocol - :param verbosity: The verbosity level applied to traces emitted by trace - policies. Possible values include: 'verbose', 'information', 'error' + :param verbosity: The verbosity level applied to traces emitted by trace policies. Possible + values include: "verbose", "information", "error". :type verbosity: str or ~azure.mgmt.apimanagement.models.Verbosity + :param operation_name_format: The format of the Operation Name for Application Insights + telemetries. Default is Name. Possible values include: "Name", "Url". + :type operation_name_format: str or ~azure.mgmt.apimanagement.models.OperationNameFormat """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'logger_id': {'required': True}, } _attribute_map = { @@ -3317,9 +5256,23 @@ class DiagnosticContract(Resource): 'log_client_ip': {'key': 'properties.logClientIp', 'type': 'bool'}, 'http_correlation_protocol': {'key': 'properties.httpCorrelationProtocol', 'type': 'str'}, 'verbosity': {'key': 'properties.verbosity', 'type': 'str'}, - } - - def __init__(self, *, logger_id: str, always_log=None, sampling=None, frontend=None, backend=None, log_client_ip: bool=None, http_correlation_protocol=None, verbosity=None, **kwargs) -> None: + 'operation_name_format': {'key': 'properties.operationNameFormat', 'type': 'str'}, + } + + def __init__( + self, + *, + always_log: Optional[Union[str, "AlwaysLog"]] = None, + logger_id: Optional[str] = None, + sampling: Optional["SamplingSettings"] = None, + frontend: Optional["PipelineDiagnosticSettings"] = None, + backend: Optional["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, + **kwargs + ): super(DiagnosticContract, self).__init__(**kwargs) self.always_log = always_log self.logger_id = logger_id @@ -3329,15 +5282,39 @@ def __init__(self, *, logger_id: str, always_log=None, sampling=None, frontend=N self.log_client_ip = log_client_ip self.http_correlation_protocol = http_correlation_protocol self.verbosity = verbosity + self.operation_name_format = operation_name_format + + +class EmailTemplateCollection(msrest.serialization.Model): + """Paged email template list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.EmailTemplateContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EmailTemplateContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["EmailTemplateContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(EmailTemplateCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link class EmailTemplateContract(Resource): """Email Template details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3345,17 +5322,16 @@ class EmailTemplateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param subject: Required. Subject of the Template. + :param subject: Subject of the Template. :type subject: str - :param body: Required. Email Template Body. This should be a valid - XDocument + :param body: Email Template Body. This should be a valid XDocument. :type body: str :param title: Title of the Template. :type title: str :param description: Description of the Email Template. :type description: str - :ivar is_default: Whether the template is the default template provided by - Api Management or has been edited. + :ivar is_default: Whether the template is the default template provided by Api Management or + has been edited. :vartype is_default: bool :param parameters: Email Template Parameter values. :type parameters: @@ -3366,8 +5342,8 @@ class EmailTemplateContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'subject': {'required': True, 'max_length': 1000, 'min_length': 1}, - 'body': {'required': True, 'min_length': 1}, + 'subject': {'max_length': 1000, 'min_length': 1}, + 'body': {'min_length': 1}, 'is_default': {'readonly': True}, } @@ -3383,7 +5359,16 @@ class EmailTemplateContract(Resource): 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, } - def __init__(self, *, subject: str, body: str, title: str=None, description: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + subject: Optional[str] = None, + body: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + **kwargs + ): super(EmailTemplateContract, self).__init__(**kwargs) self.subject = subject self.body = body @@ -3393,7 +5378,7 @@ def __init__(self, *, subject: str, body: str, title: str=None, description: str self.parameters = parameters -class EmailTemplateParametersContractProperties(Model): +class EmailTemplateParametersContractProperties(msrest.serialization.Model): """Email Template Parameter contract. :param name: Template parameter name. @@ -3416,14 +5401,21 @@ class EmailTemplateParametersContractProperties(Model): 'description': {'key': 'description', 'type': 'str'}, } - def __init__(self, *, name: str=None, title: str=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): super(EmailTemplateParametersContractProperties, self).__init__(**kwargs) self.name = name self.title = title self.description = description -class EmailTemplateUpdateParameters(Model): +class EmailTemplateUpdateParameters(msrest.serialization.Model): """Email Template update Parameters. :param subject: Subject of the Template. @@ -3432,7 +5424,7 @@ class EmailTemplateUpdateParameters(Model): :type title: str :param description: Description of the Email Template. :type description: str - :param body: Email Template Body. This should be a valid XDocument + :param body: Email Template Body. This should be a valid XDocument. :type body: str :param parameters: Email Template Parameter values. :type parameters: @@ -3452,7 +5444,16 @@ class EmailTemplateUpdateParameters(Model): 'parameters': {'key': 'properties.parameters', 'type': '[EmailTemplateParametersContractProperties]'}, } - def __init__(self, *, subject: str=None, title: str=None, description: str=None, body: str=None, parameters=None, **kwargs) -> None: + def __init__( + self, + *, + subject: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + body: Optional[str] = None, + parameters: Optional[List["EmailTemplateParametersContractProperties"]] = None, + **kwargs + ): super(EmailTemplateUpdateParameters, self).__init__(**kwargs) self.subject = subject self.title = title @@ -3461,7 +5462,7 @@ def __init__(self, *, subject: str=None, title: str=None, description: str=None, self.parameters = parameters -class ErrorFieldContract(Model): +class ErrorFieldContract(msrest.serialization.Model): """Error Field contract. :param code: Property level error code. @@ -3478,23 +5479,29 @@ class ErrorFieldContract(Model): 'target': {'key': 'target', 'type': 'str'}, } - def __init__(self, *, code: str=None, message: str=None, target: str=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + **kwargs + ): super(ErrorFieldContract, self).__init__(**kwargs) self.code = code self.message = message self.target = target -class ErrorResponse(Model): +class ErrorResponse(msrest.serialization.Model): """Error Response. - :param code: Service-defined error code. This code serves as a sub-status - for the HTTP error code specified in the response. + :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. :type code: str :param message: Human-readable representation of the error. :type message: str - :param details: The list of invalid fields send in request, in case of - validation error. + :param details: The list of invalid fields send in request, in case of validation error. :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ @@ -3504,35 +5511,29 @@ class ErrorResponse(Model): 'details': {'key': 'error.details', 'type': '[ErrorFieldContract]'}, } - def __init__(self, *, code: str=None, message: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[List["ErrorFieldContract"]] = None, + **kwargs + ): super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message self.details = details -class ErrorResponseException(HttpOperationError): - """Server responsed with exception of type: 'ErrorResponse'. - - :param deserialize: A deserializer - :param response: Server response to be deserialized. - """ - - def __init__(self, deserialize, response, *args): - - super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) - - -class ErrorResponseBody(Model): +class ErrorResponseBody(msrest.serialization.Model): """Error Body contract. - :param code: Service-defined error code. This code serves as a sub-status - for the HTTP error code specified in the response. + :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. :type code: str :param message: Human-readable representation of the error. :type message: str - :param details: The list of invalid fields send in request, in case of - validation error. + :param details: The list of invalid fields send in request, in case of validation error. :type details: list[~azure.mgmt.apimanagement.models.ErrorFieldContract] """ @@ -3542,18 +5543,54 @@ class ErrorResponseBody(Model): 'details': {'key': 'details', 'type': '[ErrorFieldContract]'}, } - def __init__(self, *, code: str=None, message: str=None, details=None, **kwargs) -> None: + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + details: Optional[List["ErrorFieldContract"]] = None, + **kwargs + ): super(ErrorResponseBody, self).__init__(**kwargs) self.code = code self.message = message self.details = details +class GatewayCollection(msrest.serialization.Model): + """Paged Gateway list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GatewayContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GatewayCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class GatewayContract(Resource): """Gateway details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3562,9 +5599,8 @@ class GatewayContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param location_data: Gateway location. - :type location_data: - ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. :type description: str """ @@ -3572,7 +5608,7 @@ class GatewayContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, } _attribute_map = { @@ -3583,17 +5619,52 @@ class GatewayContract(Resource): 'description': {'key': 'properties.description', 'type': 'str'}, } - def __init__(self, *, location_data=None, description: str=None, **kwargs) -> None: + def __init__( + self, + *, + location_data: Optional["ResourceLocationDataContract"] = None, + description: Optional[str] = None, + **kwargs + ): super(GatewayContract, self).__init__(**kwargs) self.location_data = location_data self.description = description +class GatewayHostnameConfigurationCollection(msrest.serialization.Model): + """Paged Gateway hostname configuration list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[GatewayHostnameConfigurationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(GatewayHostnameConfigurationCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class GatewayHostnameConfigurationContract(Resource): """Gateway hostname configuration details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3601,15 +5672,19 @@ class GatewayHostnameConfigurationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param hostname: Hostname value. Supports valid domain name, partial or - full wildcard + :param hostname: Hostname value. Supports valid domain name, partial or full wildcard. :type hostname: str - :param certificate_id: Identifier of Certificate entity that will be used - for TLS connection establishment + :param certificate_id: Identifier of Certificate entity that will be used for TLS connection + establishment. :type certificate_id: str - :param negotiate_client_certificate: Determines whether gateway requests - client certificate + :param negotiate_client_certificate: Determines whether gateway requests client certificate. :type negotiate_client_certificate: bool + :param tls10_enabled: Specifies if TLS 1.0 is supported. + :type tls10_enabled: bool + :param tls11_enabled: Specifies if TLS 1.1 is supported. + :type tls11_enabled: bool + :param http2_enabled: Specifies if HTTP/2.0 is supported. + :type http2_enabled: bool """ _validation = { @@ -3625,22 +5700,38 @@ class GatewayHostnameConfigurationContract(Resource): 'hostname': {'key': 'properties.hostname', 'type': 'str'}, 'certificate_id': {'key': 'properties.certificateId', 'type': 'str'}, 'negotiate_client_certificate': {'key': 'properties.negotiateClientCertificate', 'type': 'bool'}, - } - - def __init__(self, *, hostname: str=None, certificate_id: str=None, negotiate_client_certificate: bool=None, **kwargs) -> None: + 'tls10_enabled': {'key': 'properties.tls10Enabled', 'type': 'bool'}, + 'tls11_enabled': {'key': 'properties.tls11Enabled', 'type': 'bool'}, + 'http2_enabled': {'key': 'properties.http2Enabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + hostname: Optional[str] = None, + certificate_id: Optional[str] = None, + negotiate_client_certificate: Optional[bool] = None, + tls10_enabled: Optional[bool] = None, + tls11_enabled: Optional[bool] = None, + http2_enabled: Optional[bool] = None, + **kwargs + ): super(GatewayHostnameConfigurationContract, self).__init__(**kwargs) self.hostname = hostname self.certificate_id = certificate_id self.negotiate_client_certificate = negotiate_client_certificate + self.tls10_enabled = tls10_enabled + self.tls11_enabled = tls11_enabled + self.http2_enabled = http2_enabled -class GatewayKeyRegenerationRequestContract(Model): +class GatewayKeyRegenerationRequestContract(msrest.serialization.Model): """Gateway key regeneration request contract properties. All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key being regenerated. Possible values - include: 'primary', 'secondary' + :param key_type: Required. The Key being regenerated. Possible values include: "primary", + "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType """ @@ -3649,15 +5740,20 @@ class GatewayKeyRegenerationRequestContract(Model): } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'keyType', 'type': 'str'}, } - def __init__(self, *, key_type, **kwargs) -> None: + def __init__( + self, + *, + key_type: Union[str, "KeyType"], + **kwargs + ): super(GatewayKeyRegenerationRequestContract, self).__init__(**kwargs) self.key_type = key_type -class GatewayKeysContract(Model): +class GatewayKeysContract(msrest.serialization.Model): """Gateway authentication keys. :param primary: Primary gateway key. @@ -3671,13 +5767,19 @@ class GatewayKeysContract(Model): 'secondary': {'key': 'secondary', 'type': 'str'}, } - def __init__(self, *, primary: str=None, secondary: str=None, **kwargs) -> None: + def __init__( + self, + *, + primary: Optional[str] = None, + secondary: Optional[str] = None, + **kwargs + ): super(GatewayKeysContract, self).__init__(**kwargs) self.primary = primary self.secondary = secondary -class GatewayTokenContract(Model): +class GatewayTokenContract(msrest.serialization.Model): """Gateway access token. :param value: Shared Access Authentication token value for the Gateway. @@ -3688,24 +5790,28 @@ class GatewayTokenContract(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): super(GatewayTokenContract, self).__init__(**kwargs) self.value = value -class GatewayTokenRequestContract(Model): +class GatewayTokenRequestContract(msrest.serialization.Model): """Gateway token request contract properties. All required parameters must be populated in order to send to Azure. - :param key_type: Required. The Key to be used to generate gateway token. - Possible values include: 'primary', 'secondary'. Default value: "primary" - . + :param key_type: Required. The Key to be used to generate gateway token. Possible values + include: "primary", "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: Required. The Expiry time of the Token. Maximum token - expiry time is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime + :param expiry: Required. The Expiry time of the Token. Maximum token expiry time is set to 30 + days. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the + ISO 8601 standard. + :type expiry: ~datetime.datetime """ _validation = { @@ -3714,17 +5820,23 @@ class GatewayTokenRequestContract(Model): } _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'keyType', 'type': 'str'}, 'expiry': {'key': 'expiry', 'type': 'iso-8601'}, } - def __init__(self, *, expiry, key_type="primary", **kwargs) -> None: + def __init__( + self, + *, + key_type: Union[str, "KeyType"], + expiry: datetime.datetime, + **kwargs + ): super(GatewayTokenRequestContract, self).__init__(**kwargs) self.key_type = key_type self.expiry = expiry -class GenerateSsoUrlResult(Model): +class GenerateSsoUrlResult(msrest.serialization.Model): """Generate SSO Url operations response details. :param value: Redirect Url containing the SSO URL value. @@ -3735,18 +5847,46 @@ class GenerateSsoUrlResult(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): super(GenerateSsoUrlResult, self).__init__(**kwargs) self.value = value -class GroupContract(Resource): - """Contract details. +class GroupCollection(msrest.serialization.Model): + """Paged Group list representation. - Variables are only populated by the server, and will be ignored when - sending a request. + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.GroupContract] + :param next_link: Next page link if any. + :type next_link: str + """ - All required parameters must be populated in order to send to Azure. + _attribute_map = { + 'value': {'key': 'value', 'type': '[GroupContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["GroupContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(GroupCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class GroupContract(Resource): + """Contract details. + + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -3754,21 +5894,19 @@ class GroupContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. Group name. + :param display_name: Group name. :type display_name: str :param description: Group description. Can contain HTML formatting tags. :type description: str - :ivar built_in: true if the group is one of the three system groups - (Administrators, Developers, or Guests); otherwise false. + :ivar built_in: true if the group is one of the three system groups (Administrators, + Developers, or Guests); otherwise false. :vartype built_in: bool - :param group_contract_type: Group type. Possible values include: 'custom', - 'system', 'external' - :type group_contract_type: str or - ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of - the group from the external identity provider, e.g. for Azure Active - Directory `aad://.onmicrosoft.com/groups/`; - otherwise the value is null. + :param type_properties_type: Group type. Possible values include: "custom", "system", + "external". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.GroupType + :param external_id: For external groups, this property contains the id of the group from the + external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ @@ -3776,8 +5914,8 @@ class GroupContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'description': {'max_length': 1000, 'min_length': 0}, 'built_in': {'readonly': True}, } @@ -3788,24 +5926,31 @@ class GroupContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'built_in': {'key': 'properties.builtIn', 'type': 'bool'}, - 'group_contract_type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, *, display_name: str, description: str=None, group_contract_type=None, external_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + type_properties_type: Optional[Union[str, "GroupType"]] = None, + external_id: Optional[str] = None, + **kwargs + ): super(GroupContract, self).__init__(**kwargs) self.display_name = display_name self.description = description self.built_in = None - self.group_contract_type = group_contract_type + self.type_properties_type = type_properties_type self.external_id = external_id -class GroupContractProperties(Model): +class GroupContractProperties(msrest.serialization.Model): """Group contract Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. @@ -3813,22 +5958,20 @@ class GroupContractProperties(Model): :type display_name: str :param description: Group description. Can contain HTML formatting tags. :type description: str - :ivar built_in: true if the group is one of the three system groups - (Administrators, Developers, or Guests); otherwise false. + :ivar built_in: true if the group is one of the three system groups (Administrators, + Developers, or Guests); otherwise false. :vartype built_in: bool - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: For external groups, this property contains the id of - the group from the external identity provider, e.g. for Azure Active - Directory `aad://.onmicrosoft.com/groups/`; - otherwise the value is null. + :param external_id: For external groups, this property contains the id of the group from the + external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ _validation = { 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, 'built_in': {'readonly': True}, } @@ -3836,11 +5979,19 @@ class GroupContractProperties(Model): 'display_name': {'key': 'displayName', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'built_in': {'key': 'builtIn', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'GroupType'}, + 'type': {'key': 'type', 'type': 'str'}, 'external_id': {'key': 'externalId', 'type': 'str'}, } - def __init__(self, *, display_name: str, description: str=None, type=None, external_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + type: Optional[Union[str, "GroupType"]] = None, + external_id: Optional[str] = None, + **kwargs + ): super(GroupContractProperties, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -3849,37 +6000,41 @@ def __init__(self, *, display_name: str, description: str=None, type=None, exter self.external_id = external_id -class GroupCreateParameters(Model): +class GroupCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create Group operation. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. Group name. + :param display_name: Group name. :type display_name: str :param description: Group description. :type description: str - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property - contains the id of the group from the external identity provider, e.g. for - Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + :param external_id: Identifier of the external groups, this property contains the id of the + group from the external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ _validation = { - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, } _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, *, display_name: str, description: str=None, type=None, external_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + type: Optional[Union[str, "GroupType"]] = None, + external_id: Optional[str] = None, + **kwargs + ): super(GroupCreateParameters, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -3887,20 +6042,18 @@ def __init__(self, *, display_name: str, description: str=None, type=None, exter self.external_id = external_id -class GroupUpdateParameters(Model): +class GroupUpdateParameters(msrest.serialization.Model): """Parameters supplied to the Update Group operation. :param display_name: Group name. :type display_name: str :param description: Group description. :type description: str - :param type: Group type. Possible values include: 'custom', 'system', - 'external' + :param type: Group type. Possible values include: "custom", "system", "external". :type type: str or ~azure.mgmt.apimanagement.models.GroupType - :param external_id: Identifier of the external groups, this property - contains the id of the group from the external identity provider, e.g. for - Azure Active Directory `aad://.onmicrosoft.com/groups/`; otherwise the value is null. + :param external_id: Identifier of the external groups, this property contains the id of the + group from the external identity provider, e.g. for Azure Active Directory + ``aad://.onmicrosoft.com/groups/``\ ; otherwise the value is null. :type external_id: str """ @@ -3911,11 +6064,19 @@ class GroupUpdateParameters(Model): _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'GroupType'}, + 'type': {'key': 'properties.type', 'type': 'str'}, 'external_id': {'key': 'properties.externalId', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, description: str=None, type=None, external_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + type: Optional[Union[str, "GroupType"]] = None, + external_id: Optional[str] = None, + **kwargs + ): super(GroupUpdateParameters, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -3923,37 +6084,36 @@ def __init__(self, *, display_name: str=None, description: str=None, type=None, self.external_id = external_id -class HostnameConfiguration(Model): +class HostnameConfiguration(msrest.serialization.Model): """Custom hostname configuration. All required parameters must be populated in order to send to Azure. - :param type: Required. Hostname type. Possible values include: 'Proxy', - 'Portal', 'Management', 'Scm', 'DeveloperPortal' + :param type: Required. Hostname type. Possible values include: "Proxy", "Portal", "Management", + "Scm", "DeveloperPortal". :type type: str or ~azure.mgmt.apimanagement.models.HostnameType - :param host_name: Required. Hostname to configure on the Api Management - service. + :param host_name: Required. Hostname to configure on the Api Management service. :type host_name: str - :param key_vault_id: Url to the KeyVault Secret containing the Ssl - Certificate. If absolute Url containing version is provided, auto-update - of ssl certificate will not work. This requires Api Management service to - be configured with MSI. The secret should be of type - *application/x-pkcs12* + :param key_vault_id: Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url + containing version is provided, auto-update of ssl certificate will not work. This requires Api + Management service to be configured with MSI. The secret should be of type + *application/x-pkcs12*. :type key_vault_id: str + :param identity_client_id: System or User Assigned Managed identity clientId as generated by + Azure AD, which has GET access to the keyVault containing the SSL certificate. + :type identity_client_id: str :param encoded_certificate: Base64 Encoded certificate. :type encoded_certificate: str :param certificate_password: Certificate Password. :type certificate_password: str - :param default_ssl_binding: Specify true to setup the certificate - associated with this Hostname as the Default SSL Certificate. If a client - does not send the SNI header, then this will be the certificate that will - be challenged. The property is useful if a service has multiple custom - hostname enabled and it needs to decide on the default ssl certificate. - The setting only applied to Proxy Hostname Type. Default value: False . + :param default_ssl_binding: Specify true to setup the certificate associated with this Hostname + as the Default SSL Certificate. If a client does not send the SNI header, then this will be the + certificate that will be challenged. The property is useful if a service has multiple custom + hostname enabled and it needs to decide on the default ssl certificate. The setting only + applied to Proxy Hostname Type. :type default_ssl_binding: bool - :param negotiate_client_certificate: Specify true to always negotiate - client certificate on the hostname. Default Value is false. Default value: - False . + :param negotiate_client_certificate: Specify true to always negotiate client certificate on the + hostname. Default Value is false. :type negotiate_client_certificate: bool :param certificate: Certificate information. :type certificate: ~azure.mgmt.apimanagement.models.CertificateInformation @@ -3968,6 +6128,7 @@ class HostnameConfiguration(Model): 'type': {'key': 'type', 'type': 'str'}, 'host_name': {'key': 'hostName', 'type': 'str'}, 'key_vault_id': {'key': 'keyVaultId', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, 'encoded_certificate': {'key': 'encodedCertificate', 'type': 'str'}, 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, 'default_ssl_binding': {'key': 'defaultSslBinding', 'type': 'bool'}, @@ -3975,11 +6136,25 @@ class HostnameConfiguration(Model): 'certificate': {'key': 'certificate', 'type': 'CertificateInformation'}, } - def __init__(self, *, type, host_name: str, key_vault_id: str=None, encoded_certificate: str=None, certificate_password: str=None, default_ssl_binding: bool=False, negotiate_client_certificate: bool=False, certificate=None, **kwargs) -> None: + def __init__( + self, + *, + type: Union[str, "HostnameType"], + host_name: str, + key_vault_id: Optional[str] = None, + identity_client_id: Optional[str] = None, + encoded_certificate: Optional[str] = None, + certificate_password: Optional[str] = None, + default_ssl_binding: Optional[bool] = False, + negotiate_client_certificate: Optional[bool] = False, + certificate: Optional["CertificateInformation"] = None, + **kwargs + ): super(HostnameConfiguration, self).__init__(**kwargs) self.type = type self.host_name = host_name self.key_vault_id = key_vault_id + self.identity_client_id = identity_client_id self.encoded_certificate = encoded_certificate self.certificate_password = certificate_password self.default_ssl_binding = default_ssl_binding @@ -3987,57 +6162,63 @@ def __init__(self, *, type, host_name: str, key_vault_id: str=None, encoded_cert self.certificate = certificate -class HttpMessageDiagnostic(Model): +class HttpMessageDiagnostic(msrest.serialization.Model): """Http message diagnostic settings. :param headers: Array of HTTP Headers to log. :type headers: list[str] :param body: Body logging settings. :type body: ~azure.mgmt.apimanagement.models.BodyDiagnosticSettings + :param data_masking: Data masking settings. + :type data_masking: ~azure.mgmt.apimanagement.models.DataMasking """ _attribute_map = { 'headers': {'key': 'headers', 'type': '[str]'}, 'body': {'key': 'body', 'type': 'BodyDiagnosticSettings'}, + 'data_masking': {'key': 'dataMasking', 'type': 'DataMasking'}, } - def __init__(self, *, headers=None, body=None, **kwargs) -> None: + def __init__( + self, + *, + headers: Optional[List[str]] = None, + body: Optional["BodyDiagnosticSettings"] = None, + data_masking: Optional["DataMasking"] = None, + **kwargs + ): super(HttpMessageDiagnostic, self).__init__(**kwargs) self.headers = headers self.body = body + self.data_masking = data_masking -class IdentityProviderBaseParameters(Model): +class IdentityProviderBaseParameters(msrest.serialization.Model): """Identity Provider Base Parameter Properties. - :param type: Identity Provider Type identifier. Possible values include: - 'facebook', 'google', 'microsoft', 'twitter', 'aad', 'aadB2C' + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str """ _validation = { - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, @@ -4055,7 +6236,19 @@ class IdentityProviderBaseParameters(Model): 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, } - def __init__(self, *, type=None, signin_tenant: str=None, allowed_tenants=None, authority: str=None, signup_policy_name: str=None, signin_policy_name: str=None, profile_editing_policy_name: str=None, password_reset_policy_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + **kwargs + ): super(IdentityProviderBaseParameters, self).__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant @@ -4070,10 +6263,7 @@ def __init__(self, *, type=None, signin_tenant: str=None, allowed_tenants=None, class IdentityProviderContract(Resource): """Identity Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4081,41 +6271,32 @@ class IdentityProviderContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param identity_provider_contract_type: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_contract_type: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external - Identity Provider. It is App ID for Facebook login, Client ID for Google - login, App ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Client secret of the Application in external - Identity Provider, used to authenticate login request. For example, it is - App Secret for Facebook login, API Key for Google login, Public Key for - Microsoft. This property will not be filled on 'GET' operations! Use - '/listSecrets' POST request to get the value. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type client_secret: str """ @@ -4123,12 +6304,12 @@ class IdentityProviderContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, - 'client_id': {'required': True, 'min_length': 1}, + 'client_id': {'min_length': 1}, 'client_secret': {'min_length': 1}, } @@ -4136,7 +6317,7 @@ class IdentityProviderContract(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'identity_provider_contract_type': {'key': 'properties.type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'signin_tenant': {'key': 'properties.signinTenant', 'type': 'str'}, 'allowed_tenants': {'key': 'properties.allowedTenants', 'type': '[str]'}, 'authority': {'key': 'properties.authority', 'type': 'str'}, @@ -4148,9 +6329,23 @@ class IdentityProviderContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, client_id: str, identity_provider_contract_type=None, signin_tenant: str=None, allowed_tenants=None, authority: str=None, signup_policy_name: str=None, signin_policy_name: str=None, profile_editing_policy_name: str=None, password_reset_policy_name: str=None, client_secret: str=None, **kwargs) -> None: + def __init__( + self, + *, + type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(IdentityProviderContract, self).__init__(**kwargs) - self.identity_provider_contract_type = identity_provider_contract_type + self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants self.authority = authority @@ -4162,13 +6357,87 @@ def __init__(self, *, client_id: str, identity_provider_contract_type=None, sign self.client_secret = client_secret +class IdentityProviderContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. + + All required parameters must be populated in order to send to Azure. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Required. Client Id of the Application in the external Identity Provider. It + is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'required': True, 'min_length': 1}, + 'client_secret': {'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + *, + client_id: str, + type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_secret: Optional[str] = None, + **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, **kwargs) + self.client_id = client_id + self.client_secret = client_secret + + class IdentityProviderCreateContract(Resource): """Identity Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4176,41 +6445,32 @@ class IdentityProviderCreateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param identity_provider_create_contract_type: Identity Provider Type - identifier. Possible values include: 'facebook', 'google', 'microsoft', - 'twitter', 'aad', 'aadB2C' - :type identity_provider_create_contract_type: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param type_properties_type: Identity Provider Type identifier. Possible values include: + "facebook", "google", "microsoft", "twitter", "aad", "aadB2C". + :type type_properties_type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C - Identity Provider. + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Required. Client Id of the Application in the external - Identity Provider. It is App ID for Facebook login, Client ID for Google - login, App ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Required. Client secret of the Application in - external Identity Provider, used to authenticate login request. For - example, it is App Secret for Facebook login, API Key for Google login, - Public Key for Microsoft. This property will not be filled on 'GET' - operations! Use '/listSecrets' POST request to get the value. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. This property will not be filled on 'GET' operations! + Use '/listSecrets' POST request to get the value. :type client_secret: str """ @@ -4218,20 +6478,20 @@ class IdentityProviderCreateContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, 'password_reset_policy_name': {'min_length': 1}, - 'client_id': {'required': True, 'min_length': 1}, - 'client_secret': {'required': True, 'min_length': 1}, + 'client_id': {'min_length': 1}, + 'client_secret': {'min_length': 1}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'identity_provider_create_contract_type': {'key': 'properties.type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, 'signin_tenant': {'key': 'properties.signinTenant', 'type': 'str'}, 'allowed_tenants': {'key': 'properties.allowedTenants', 'type': '[str]'}, 'authority': {'key': 'properties.authority', 'type': 'str'}, @@ -4243,9 +6503,23 @@ class IdentityProviderCreateContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, client_id: str, client_secret: str, identity_provider_create_contract_type=None, signin_tenant: str=None, allowed_tenants=None, authority: str=None, signup_policy_name: str=None, signin_policy_name: str=None, profile_editing_policy_name: str=None, password_reset_policy_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + type_properties_type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(IdentityProviderCreateContract, self).__init__(**kwargs) - self.identity_provider_create_contract_type = identity_provider_create_contract_type + self.type_properties_type = type_properties_type self.signin_tenant = signin_tenant self.allowed_tenants = allowed_tenants self.authority = authority @@ -4257,46 +6531,142 @@ def __init__(self, *, client_id: str, client_secret: str, identity_provider_crea self.client_secret = client_secret -class IdentityProviderUpdateParameters(Model): - """Parameters supplied to update Identity Provider. +class IdentityProviderCreateContractProperties(IdentityProviderBaseParameters): + """The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be used to enable access to the API Management service developer portal for all users. + + All required parameters must be populated in order to send to Azure. - :param type: Identity Provider Type identifier. Possible values include: - 'facebook', 'google', 'microsoft', 'twitter', 'aad', 'aadB2C' + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType - :param signin_tenant: The TenantId to use instead of Common when logging - into Active Directory + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. :type signin_tenant: str - :param allowed_tenants: List of Allowed Tenants when configuring Azure - Active Directory login. + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. :type allowed_tenants: list[str] - :param authority: OpenID Connect discovery endpoint hostname for AAD or - AAD B2C. + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. :type authority: str - :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C - Identity Provider. + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. :type signup_policy_name: str - :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Required. Client Id of the Application in the external Identity Provider. It + is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Required. Client secret of the Application in external Identity Provider, + used to authenticate login request. For example, it is App Secret for Facebook login, API Key + for Google login, Public Key for Microsoft. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'required': True, 'min_length': 1}, + 'client_secret': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + *, + client_id: str, + client_secret: str, + type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + **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, **kwargs) + self.client_id = client_id + self.client_secret = client_secret + + +class IdentityProviderList(msrest.serialization.Model): + """List of all the Identity Providers configured on the service instance. + + :param value: Identity Provider configuration values. + :type value: list[~azure.mgmt.apimanagement.models.IdentityProviderContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IdentityProviderContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["IdentityProviderContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(IdentityProviderList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class IdentityProviderUpdateParameters(msrest.serialization.Model): + """Parameters supplied to update Identity Provider. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. :type signin_policy_name: str - :param profile_editing_policy_name: Profile Editing Policy Name. Only - applies to AAD B2C Identity Provider. + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. :type profile_editing_policy_name: str - :param password_reset_policy_name: Password Reset Policy Name. Only - applies to AAD B2C Identity Provider. + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. :type password_reset_policy_name: str - :param client_id: Client Id of the Application in the external Identity - Provider. It is App ID for Facebook login, Client ID for Google login, App - ID for Microsoft. + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. :type client_id: str - :param client_secret: Client secret of the Application in external - Identity Provider, used to authenticate login request. For example, it is - App Secret for Facebook login, API Key for Google login, Public Key for - Microsoft. + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. :type client_secret: str """ _validation = { - 'allowed_tenants': {'max_items': 32}, + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, 'signup_policy_name': {'min_length': 1}, 'signin_policy_name': {'min_length': 1}, 'profile_editing_policy_name': {'min_length': 1}, @@ -4318,7 +6688,21 @@ class IdentityProviderUpdateParameters(Model): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, type=None, signin_tenant: str=None, allowed_tenants=None, authority: str=None, signup_policy_name: str=None, signin_policy_name: str=None, profile_editing_policy_name: str=None, password_reset_policy_name: str=None, client_id: str=None, client_secret: str=None, **kwargs) -> None: + def __init__( + self, + *, + type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(IdentityProviderUpdateParameters, self).__init__(**kwargs) self.type = type self.signin_tenant = signin_tenant @@ -4332,13 +6716,114 @@ def __init__(self, *, type=None, signin_tenant: str=None, allowed_tenants=None, self.client_secret = client_secret +class IdentityProviderUpdateProperties(IdentityProviderBaseParameters): + """Parameters supplied to the Update Identity Provider operation. + + :param type: Identity Provider Type identifier. Possible values include: "facebook", "google", + "microsoft", "twitter", "aad", "aadB2C". + :type type: str or ~azure.mgmt.apimanagement.models.IdentityProviderType + :param signin_tenant: The TenantId to use instead of Common when logging into Active Directory. + :type signin_tenant: str + :param allowed_tenants: List of Allowed Tenants when configuring Azure Active Directory login. + :type allowed_tenants: list[str] + :param authority: OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + :type authority: str + :param signup_policy_name: Signup Policy Name. Only applies to AAD B2C Identity Provider. + :type signup_policy_name: str + :param signin_policy_name: Signin Policy Name. Only applies to AAD B2C Identity Provider. + :type signin_policy_name: str + :param profile_editing_policy_name: Profile Editing Policy Name. Only applies to AAD B2C + Identity Provider. + :type profile_editing_policy_name: str + :param password_reset_policy_name: Password Reset Policy Name. Only applies to AAD B2C Identity + Provider. + :type password_reset_policy_name: str + :param client_id: Client Id of the Application in the external Identity Provider. It is App ID + for Facebook login, Client ID for Google login, App ID for Microsoft. + :type client_id: str + :param client_secret: Client secret of the Application in external Identity Provider, used to + authenticate login request. For example, it is App Secret for Facebook login, API Key for + Google login, Public Key for Microsoft. + :type client_secret: str + """ + + _validation = { + 'allowed_tenants': {'max_items': 32, 'min_items': 0}, + 'signup_policy_name': {'min_length': 1}, + 'signin_policy_name': {'min_length': 1}, + 'profile_editing_policy_name': {'min_length': 1}, + 'password_reset_policy_name': {'min_length': 1}, + 'client_id': {'min_length': 1}, + 'client_secret': {'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'signin_tenant': {'key': 'signinTenant', 'type': 'str'}, + 'allowed_tenants': {'key': 'allowedTenants', 'type': '[str]'}, + 'authority': {'key': 'authority', 'type': 'str'}, + 'signup_policy_name': {'key': 'signupPolicyName', 'type': 'str'}, + 'signin_policy_name': {'key': 'signinPolicyName', 'type': 'str'}, + 'profile_editing_policy_name': {'key': 'profileEditingPolicyName', 'type': 'str'}, + 'password_reset_policy_name': {'key': 'passwordResetPolicyName', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + 'client_secret': {'key': 'clientSecret', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "IdentityProviderType"]] = None, + signin_tenant: Optional[str] = None, + allowed_tenants: Optional[List[str]] = None, + authority: Optional[str] = None, + signup_policy_name: Optional[str] = None, + signin_policy_name: Optional[str] = None, + profile_editing_policy_name: Optional[str] = None, + password_reset_policy_name: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **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, **kwargs) + self.client_id = client_id + self.client_secret = client_secret + + +class IssueAttachmentCollection(msrest.serialization.Model): + """Paged Issue Attachment list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue Attachment values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueAttachmentContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueAttachmentContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueAttachmentCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class IssueAttachmentContract(Resource): """Issue Attachment Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4346,13 +6831,12 @@ class IssueAttachmentContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param title: Required. Filename by which the binary data will be saved. + :param title: Filename by which the binary data will be saved. :type title: str - :param content_format: Required. Either 'link' if content is provided via - an HTTP link or the MIME type of the Base64-encoded binary data provided - in the 'content' property. + :param content_format: Either 'link' if content is provided via an HTTP link or the MIME type + of the Base64-encoded binary data provided in the 'content' property. :type content_format: str - :param content: Required. An HTTP link or Base64-encoded binary data. + :param content: An HTTP link or Base64-encoded binary data. :type content: str """ @@ -4360,9 +6844,6 @@ class IssueAttachmentContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True}, - 'content_format': {'required': True}, - 'content': {'required': True}, } _attribute_map = { @@ -4374,20 +6855,84 @@ class IssueAttachmentContract(Resource): 'content': {'key': 'properties.content', 'type': 'str'}, } - def __init__(self, *, title: str, content_format: str, content: str, **kwargs) -> None: + def __init__( + self, + *, + title: Optional[str] = None, + content_format: Optional[str] = None, + content: Optional[str] = None, + **kwargs + ): super(IssueAttachmentContract, self).__init__(**kwargs) self.title = title self.content_format = content_format self.content = content +class IssueCollection(msrest.serialization.Model): + """Paged Issue list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class IssueCommentCollection(msrest.serialization.Model): + """Paged Issue Comment list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Issue Comment values. + :vartype value: list[~azure.mgmt.apimanagement.models.IssueCommentContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[IssueCommentContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(IssueCommentCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class IssueCommentContract(Resource): """Issue Comment Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4395,12 +6940,11 @@ class IssueCommentContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param text: Required. Comment text. + :param text: Comment text. :type text: str :param created_date: Date and time when the comment was created. - :type created_date: datetime - :param user_id: Required. A resource identifier for the user who left the - comment. + :type created_date: ~datetime.datetime + :param user_id: A resource identifier for the user who left the comment. :type user_id: str """ @@ -4408,8 +6952,6 @@ class IssueCommentContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'text': {'required': True}, - 'user_id': {'required': True}, } _attribute_map = { @@ -4421,7 +6963,14 @@ class IssueCommentContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, *, text: str, user_id: str, created_date=None, **kwargs) -> None: + def __init__( + self, + *, + text: Optional[str] = None, + created_date: Optional[datetime.datetime] = None, + user_id: Optional[str] = None, + **kwargs + ): super(IssueCommentContract, self).__init__(**kwargs) self.text = text self.created_date = created_date @@ -4431,10 +6980,7 @@ def __init__(self, *, text: str, user_id: str, created_date=None, **kwargs) -> N class IssueContract(Resource): """Issue Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4443,19 +6989,17 @@ class IssueContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str - :param title: Required. The issue title. + :param title: The issue title. :type title: str - :param description: Required. Text describing the issue. + :param description: Text describing the issue. :type description: str - :param user_id: Required. A resource identifier for the user created the - issue. + :param user_id: A resource identifier for the user created the issue. :type user_id: str """ @@ -4463,9 +7007,6 @@ class IssueContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True}, - 'description': {'required': True}, - 'user_id': {'required': True}, } _attribute_map = { @@ -4480,7 +7021,17 @@ class IssueContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, *, title: str, description: str, user_id: str, created_date=None, state=None, api_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "State"]] = None, + api_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + user_id: Optional[str] = None, + **kwargs + ): super(IssueContract, self).__init__(**kwargs) self.created_date = created_date self.state = state @@ -4490,16 +7041,15 @@ def __init__(self, *, title: str, description: str, user_id: str, created_date=N self.user_id = user_id -class IssueContractBaseProperties(Model): +class IssueContractBaseProperties(msrest.serialization.Model): """Issue contract Base Properties. :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str """ @@ -4509,42 +7059,110 @@ class IssueContractBaseProperties(Model): 'api_id': {'key': 'apiId', 'type': 'str'}, } - def __init__(self, *, created_date=None, state=None, api_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "State"]] = None, + api_id: Optional[str] = None, + **kwargs + ): super(IssueContractBaseProperties, self).__init__(**kwargs) self.created_date = created_date self.state = state self.api_id = api_id -class IssueUpdateContract(Model): - """Issue update Parameters. +class IssueContractProperties(IssueContractBaseProperties): + """Issue contract Properties. + + All required parameters must be populated in order to send to Azure. :param created_date: Date and time when the issue was created. - :type created_date: datetime - :param state: Status of the issue. Possible values include: 'proposed', - 'open', 'removed', 'resolved', 'closed' + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". :type state: str or ~azure.mgmt.apimanagement.models.State - :param api_id: A resource identifier for the API the issue was created - for. + :param api_id: A resource identifier for the API the issue was created for. :type api_id: str - :param title: The issue title. + :param title: Required. The issue title. :type title: str - :param description: Text describing the issue. + :param description: Required. Text describing the issue. :type description: str - :param user_id: A resource identifier for the user created the issue. + :param user_id: Required. A resource identifier for the user created the issue. :type user_id: str """ + _validation = { + 'title': {'required': True}, + 'description': {'required': True}, + 'user_id': {'required': True}, + } + _attribute_map = { - 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'api_id': {'key': 'properties.apiId', 'type': 'str'}, + 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, + 'state': {'key': 'state', 'type': 'str'}, + 'api_id': {'key': 'apiId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + } + + def __init__( + self, + *, + title: str, + description: str, + user_id: str, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "State"]] = None, + api_id: Optional[str] = None, + **kwargs + ): + super(IssueContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) + self.title = title + self.description = description + self.user_id = user_id + + +class IssueUpdateContract(msrest.serialization.Model): + """Issue update Parameters. + + :param created_date: Date and time when the issue was created. + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". + :type state: str or ~azure.mgmt.apimanagement.models.State + :param api_id: A resource identifier for the API the issue was created for. + :type api_id: str + :param title: The issue title. + :type title: str + :param description: Text describing the issue. + :type description: str + :param user_id: A resource identifier for the user created the issue. + :type user_id: str + """ + + _attribute_map = { + 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'api_id': {'key': 'properties.apiId', 'type': 'str'}, 'title': {'key': 'properties.title', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, *, created_date=None, state=None, api_id: str=None, title: str=None, description: str=None, user_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "State"]] = None, + api_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + user_id: Optional[str] = None, + **kwargs + ): super(IssueUpdateContract, self).__init__(**kwargs) self.created_date = created_date self.state = state @@ -4554,13 +7172,174 @@ def __init__(self, *, created_date=None, state=None, api_id: str=None, title: st self.user_id = user_id +class IssueUpdateContractProperties(IssueContractBaseProperties): + """Issue contract Update Properties. + + :param created_date: Date and time when the issue was created. + :type created_date: ~datetime.datetime + :param state: Status of the issue. Possible values include: "proposed", "open", "removed", + "resolved", "closed". + :type state: str or ~azure.mgmt.apimanagement.models.State + :param api_id: A resource identifier for the API the issue was created for. + :type api_id: str + :param title: The issue title. + :type title: str + :param description: Text describing the issue. + :type description: str + :param user_id: A resource identifier for the user created the issue. + :type user_id: str + """ + + _attribute_map = { + 'created_date': {'key': 'createdDate', 'type': 'iso-8601'}, + 'state': {'key': 'state', 'type': 'str'}, + 'api_id': {'key': 'apiId', 'type': 'str'}, + 'title': {'key': 'title', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'user_id': {'key': 'userId', 'type': 'str'}, + } + + def __init__( + self, + *, + created_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "State"]] = None, + api_id: Optional[str] = None, + title: Optional[str] = None, + description: Optional[str] = None, + user_id: Optional[str] = None, + **kwargs + ): + super(IssueUpdateContractProperties, self).__init__(created_date=created_date, state=state, api_id=api_id, **kwargs) + self.title = title + self.description = description + self.user_id = user_id + + +class KeyVaultContractCreateProperties(msrest.serialization.Model): + """Create keyVault contract details. + + :param secret_identifier: Key vault secret identifier for fetching secret. + :type secret_identifier: str + :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + be used to access key vault secret. + :type identity_client_id: str + """ + + _attribute_map = { + 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, + } + + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + identity_client_id: Optional[str] = None, + **kwargs + ): + super(KeyVaultContractCreateProperties, self).__init__(**kwargs) + self.secret_identifier = secret_identifier + self.identity_client_id = identity_client_id + + +class KeyVaultContractProperties(KeyVaultContractCreateProperties): + """KeyVault contract details. + + :param secret_identifier: Key vault secret identifier for fetching secret. + :type secret_identifier: str + :param identity_client_id: SystemAssignedIdentity or UserAssignedIdentity Client Id which will + be used to access key vault secret. + :type identity_client_id: str + :param last_status: Last time sync and refresh status of secret from key vault. + :type last_status: ~azure.mgmt.apimanagement.models.KeyVaultLastAccessStatusContractProperties + """ + + _attribute_map = { + 'secret_identifier': {'key': 'secretIdentifier', 'type': 'str'}, + 'identity_client_id': {'key': 'identityClientId', 'type': 'str'}, + 'last_status': {'key': 'lastStatus', 'type': 'KeyVaultLastAccessStatusContractProperties'}, + } + + def __init__( + self, + *, + secret_identifier: Optional[str] = None, + identity_client_id: Optional[str] = None, + last_status: Optional["KeyVaultLastAccessStatusContractProperties"] = None, + **kwargs + ): + super(KeyVaultContractProperties, self).__init__(secret_identifier=secret_identifier, identity_client_id=identity_client_id, **kwargs) + self.last_status = last_status + + +class KeyVaultLastAccessStatusContractProperties(msrest.serialization.Model): + """Issue contract Update Properties. + + :param code: Last status code for sync and refresh of secret from key vault. + :type code: str + :param message: Details of the error else empty. + :type message: str + :param time_stamp_utc: Last time secret was accessed. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type time_stamp_utc: ~datetime.datetime + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time_stamp_utc': {'key': 'timeStampUtc', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + time_stamp_utc: Optional[datetime.datetime] = None, + **kwargs + ): + super(KeyVaultLastAccessStatusContractProperties, self).__init__(**kwargs) + self.code = code + self.message = message + self.time_stamp_utc = time_stamp_utc + + +class LoggerCollection(msrest.serialization.Model): + """Paged Logger list representation. + + :param value: Logger values. + :type value: list[~azure.mgmt.apimanagement.models.LoggerContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LoggerContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["LoggerContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(LoggerCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + class LoggerContract(Resource): """Logger details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4568,20 +7347,20 @@ class LoggerContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param logger_type: Required. Logger type. Possible values include: - 'azureEventHub', 'applicationInsights' + :param logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :param description: Logger description. :type description: str - :param credentials: Required. The name and SendRule connection string of - the event hub for azureEventHub logger. + :param credentials: The name and SendRule connection string of the event hub for azureEventHub + logger. Instrumentation key for applicationInsights logger. :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before - publishing. Default is assumed to be true. + :param is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. :type is_buffered: bool - :param resource_id: Azure Resource Id of a log target (either Azure Event - Hub resource or Azure Application Insights resource). + :param resource_id: Azure Resource Id of a log target (either Azure Event Hub resource or Azure + Application Insights resource). :type resource_id: str """ @@ -4589,9 +7368,7 @@ class LoggerContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'logger_type': {'required': True}, - 'description': {'max_length': 256}, - 'credentials': {'required': True}, + 'description': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -4605,7 +7382,16 @@ class LoggerContract(Resource): 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, } - def __init__(self, *, logger_type, credentials, description: str=None, is_buffered: bool=None, resource_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + logger_type: Optional[Union[str, "LoggerType"]] = None, + description: Optional[str] = None, + credentials: Optional[Dict[str, str]] = None, + is_buffered: Optional[bool] = None, + resource_id: Optional[str] = None, + **kwargs + ): super(LoggerContract, self).__init__(**kwargs) self.logger_type = logger_type self.description = description @@ -4614,18 +7400,18 @@ def __init__(self, *, logger_type, credentials, description: str=None, is_buffer self.resource_id = resource_id -class LoggerUpdateContract(Model): +class LoggerUpdateContract(msrest.serialization.Model): """Logger update contract. - :param logger_type: Logger type. Possible values include: 'azureEventHub', - 'applicationInsights' + :param logger_type: Logger type. Possible values include: "azureEventHub", + "applicationInsights", "azureMonitor". :type logger_type: str or ~azure.mgmt.apimanagement.models.LoggerType :param description: Logger description. :type description: str :param credentials: Logger credentials. :type credentials: dict[str, str] - :param is_buffered: Whether records are buffered in the logger before - publishing. Default is assumed to be true. + :param is_buffered: Whether records are buffered in the logger before publishing. Default is + assumed to be true. :type is_buffered: bool """ @@ -4636,7 +7422,15 @@ class LoggerUpdateContract(Model): 'is_buffered': {'key': 'properties.isBuffered', 'type': 'bool'}, } - def __init__(self, *, logger_type=None, description: str=None, credentials=None, is_buffered: bool=None, **kwargs) -> None: + def __init__( + self, + *, + logger_type: Optional[Union[str, "LoggerType"]] = None, + description: Optional[str] = None, + credentials: Optional[Dict[str, str]] = None, + is_buffered: Optional[bool] = None, + **kwargs + ): super(LoggerUpdateContract, self).__init__(**kwargs) self.logger_type = logger_type self.description = description @@ -4644,13 +7438,36 @@ def __init__(self, *, logger_type=None, description: str=None, credentials=None, self.is_buffered = is_buffered +class NamedValueCollection(msrest.serialization.Model): + """Paged NamedValue list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.NamedValueContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NamedValueContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["NamedValueContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(NamedValueCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class NamedValueContract(Resource): """NamedValue details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4658,29 +7475,30 @@ class NamedValueContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain - only letters, digits, period, dash, and underscore characters. + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It - may not be empty or consist only of whitespace. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'max_items': 32}, - 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'max_length': 4096, 'min_length': 1}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, } _attribute_map = { @@ -4691,23 +7509,115 @@ class NamedValueContract(Resource): 'secret': {'key': 'properties.secret', 'type': 'bool'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractProperties'}, + } + + def __init__( + self, + *, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + display_name: Optional[str] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractProperties"] = None, + **kwargs + ): + super(NamedValueContract, self).__init__(**kwargs) + self.tags = tags + self.secret = secret + self.display_name = display_name + self.value = value + self.key_vault = key_vault + + +class NamedValueEntityBaseParameters(msrest.serialization.Model): + """NamedValue Entity Base Parameters set. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + """ + + _validation = { + 'tags': {'max_items': 32, 'min_items': 0}, } - def __init__(self, *, display_name: str, tags=None, secret: bool=None, value: str=None, **kwargs) -> None: - super(NamedValueContract, self).__init__(**kwargs) + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + } + + def __init__( + self, + *, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + **kwargs + ): + super(NamedValueEntityBaseParameters, self).__init__(**kwargs) self.tags = tags self.secret = secret + + +class NamedValueContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + All required parameters must be populated in order to send to Azure. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + period, dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractProperties + """ + + _validation = { + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, + } + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractProperties'}, + } + + def __init__( + self, + *, + display_name: str, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractProperties"] = None, + **kwargs + ): + super(NamedValueContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) self.display_name = display_name self.value = value + self.key_vault = key_vault class NamedValueCreateContract(Resource): """NamedValue details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4715,29 +7625,30 @@ class NamedValueCreateContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Required. Unique name of NamedValue. It may contain - only letters, digits, period, dash, and underscore characters. + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. :type display_name: str - :param value: Required. Value of the NamedValue. Can contain policy - expressions. It may not be empty or consist only of whitespace. This - property will not be filled on 'GET' operations! Use '/listSecrets' POST - request to get the value. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'tags': {'max_items': 32}, - 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, - 'value': {'required': True, 'max_length': 4096, 'min_length': 1}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, } _attribute_map = { @@ -4748,61 +7659,170 @@ class NamedValueCreateContract(Resource): 'secret': {'key': 'properties.secret', 'type': 'bool'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, - } - - def __init__(self, *, display_name: str, value: str, tags=None, secret: bool=None, **kwargs) -> None: + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, + } + + def __init__( + self, + *, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + display_name: Optional[str] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractCreateProperties"] = None, + **kwargs + ): super(NamedValueCreateContract, self).__init__(**kwargs) self.tags = tags self.secret = secret self.display_name = display_name self.value = value + self.key_vault = key_vault -class NamedValueEntityBaseParameters(Model): - """NamedValue Entity Base Parameters set. +class NamedValueCreateContractProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + All required parameters must be populated in order to send to Azure. - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool + :param display_name: Required. Unique name of NamedValue. It may contain only letters, digits, + period, dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. This property will not be filled on 'GET' operations! Use + '/listSecrets' POST request to get the value. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { - 'tags': {'max_items': 32}, + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'required': True, 'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 0}, } _attribute_map = { 'tags': {'key': 'tags', 'type': '[str]'}, 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, + } + + def __init__( + self, + *, + display_name: str, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractCreateProperties"] = None, + **kwargs + ): + super(NamedValueCreateContractProperties, self).__init__(tags=tags, secret=secret, **kwargs) + self.display_name = display_name + self.value = value + self.key_vault = key_vault + + +class NamedValueSecretContract(msrest.serialization.Model): + """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + + :param value: This is secret value of the NamedValue entity. + :type value: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, tags=None, secret: bool=None, **kwargs) -> None: - super(NamedValueEntityBaseParameters, self).__init__(**kwargs) - self.tags = tags - self.secret = secret + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): + super(NamedValueSecretContract, self).__init__(**kwargs) + self.value = value + + +class NamedValueUpdateParameterProperties(NamedValueEntityBaseParameters): + """NamedValue Contract properties. + + :param tags: A set of tags. Optional tags that when provided can be used to filter the + NamedValue list. + :type tags: list[str] + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. + :type secret: bool + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. + :type display_name: str + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. + :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties + """ + _validation = { + 'tags': {'max_items': 32, 'min_items': 0}, + 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, + 'value': {'max_length': 4096, 'min_length': 1}, + } -class NamedValueUpdateParameters(Model): + _attribute_map = { + 'tags': {'key': 'tags', 'type': '[str]'}, + 'secret': {'key': 'secret', 'type': 'bool'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultContractCreateProperties'}, + } + + def __init__( + self, + *, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + display_name: Optional[str] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractCreateProperties"] = None, + **kwargs + ): + super(NamedValueUpdateParameterProperties, self).__init__(tags=tags, secret=secret, **kwargs) + self.display_name = display_name + self.value = value + self.key_vault = key_vault + + +class NamedValueUpdateParameters(msrest.serialization.Model): """NamedValue update Parameters. - :param tags: Optional tags that when provided can be used to filter the + :param tags: A set of tags. Optional tags that when provided can be used to filter the NamedValue list. :type tags: list[str] - :param secret: Determines whether the value is a secret and should be - encrypted or not. Default value is false. + :param secret: Determines whether the value is a secret and should be encrypted or not. Default + value is false. :type secret: bool - :param display_name: Unique name of NamedValue. It may contain only - letters, digits, period, dash, and underscore characters. + :param display_name: Unique name of NamedValue. It may contain only letters, digits, period, + dash, and underscore characters. :type display_name: str - :param value: Value of the NamedValue. Can contain policy expressions. It - may not be empty or consist only of whitespace. + :param value: Value of the NamedValue. Can contain policy expressions. It may not be empty or + consist only of whitespace. :type value: str + :param key_vault: KeyVault location details of the namedValue. + :type key_vault: ~azure.mgmt.apimanagement.models.KeyVaultContractCreateProperties """ _validation = { - 'tags': {'max_items': 32}, + 'tags': {'max_items': 32, 'min_items': 0}, 'display_name': {'max_length': 256, 'min_length': 1, 'pattern': r'^[A-Za-z0-9-._]+$'}, 'value': {'max_length': 4096, 'min_length': 1}, } @@ -4812,27 +7832,37 @@ class NamedValueUpdateParameters(Model): 'secret': {'key': 'properties.secret', 'type': 'bool'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'value': {'key': 'properties.value', 'type': 'str'}, - } - - def __init__(self, *, tags=None, secret: bool=None, display_name: str=None, value: str=None, **kwargs) -> None: + 'key_vault': {'key': 'properties.keyVault', 'type': 'KeyVaultContractCreateProperties'}, + } + + def __init__( + self, + *, + tags: Optional[List[str]] = None, + secret: Optional[bool] = None, + display_name: Optional[str] = None, + value: Optional[str] = None, + key_vault: Optional["KeyVaultContractCreateProperties"] = None, + **kwargs + ): super(NamedValueUpdateParameters, self).__init__(**kwargs) self.tags = tags self.secret = secret self.display_name = display_name self.value = value + self.key_vault = key_vault -class NetworkStatusContract(Model): +class NetworkStatusContract(msrest.serialization.Model): """Network Status details. All required parameters must be populated in order to send to Azure. :param dns_servers: Required. Gets the list of DNS servers IPV4 addresses. :type dns_servers: list[str] - :param connectivity_status: Required. Gets the list of Connectivity Status - to the Resources on which the service depends upon. - :type connectivity_status: - list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] + :param connectivity_status: Required. Gets the list of Connectivity Status to the Resources on + which the service depends upon. + :type connectivity_status: list[~azure.mgmt.apimanagement.models.ConnectivityStatusContract] """ _validation = { @@ -4845,20 +7875,25 @@ class NetworkStatusContract(Model): 'connectivity_status': {'key': 'connectivityStatus', 'type': '[ConnectivityStatusContract]'}, } - def __init__(self, *, dns_servers, connectivity_status, **kwargs) -> None: + def __init__( + self, + *, + dns_servers: List[str], + connectivity_status: List["ConnectivityStatusContract"], + **kwargs + ): super(NetworkStatusContract, self).__init__(**kwargs) self.dns_servers = dns_servers self.connectivity_status = connectivity_status -class NetworkStatusContractByLocation(Model): +class NetworkStatusContractByLocation(msrest.serialization.Model): """Network Status in the Location. - :param location: Location of service + :param location: Location of service. :type location: str - :param network_status: Network status in Location - :type network_status: - ~azure.mgmt.apimanagement.models.NetworkStatusContract + :param network_status: Network status in Location. + :type network_status: ~azure.mgmt.apimanagement.models.NetworkStatusContract """ _validation = { @@ -4870,19 +7905,48 @@ class NetworkStatusContractByLocation(Model): 'network_status': {'key': 'networkStatus', 'type': 'NetworkStatusContract'}, } - def __init__(self, *, location: str=None, network_status=None, **kwargs) -> None: + def __init__( + self, + *, + location: Optional[str] = None, + network_status: Optional["NetworkStatusContract"] = None, + **kwargs + ): super(NetworkStatusContractByLocation, self).__init__(**kwargs) self.location = location self.network_status = network_status +class NotificationCollection(msrest.serialization.Model): + """Paged Notification list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.NotificationContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[NotificationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["NotificationContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(NotificationCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class NotificationContract(Resource): """Notification details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4890,20 +7954,19 @@ class NotificationContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param title: Required. Title of the Notification. + :param title: Title of the Notification. :type title: str :param description: Description of the Notification. :type description: str :param recipients: Recipient Parameter values. - :type recipients: - ~azure.mgmt.apimanagement.models.RecipientsContractProperties + :type recipients: ~azure.mgmt.apimanagement.models.RecipientsContractProperties """ _validation = { 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'title': {'required': True, 'max_length': 1000, 'min_length': 1}, + 'title': {'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -4915,14 +7978,21 @@ class NotificationContract(Resource): 'recipients': {'key': 'properties.recipients', 'type': 'RecipientsContractProperties'}, } - def __init__(self, *, title: str, description: str=None, recipients=None, **kwargs) -> None: + def __init__( + self, + *, + title: Optional[str] = None, + description: Optional[str] = None, + recipients: Optional["RecipientsContractProperties"] = None, + **kwargs + ): super(NotificationContract, self).__init__(**kwargs) self.title = title self.description = description self.recipients = recipients -class OAuth2AuthenticationSettingsContract(Model): +class OAuth2AuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. :param authorization_server_id: OAuth authorization server identifier. @@ -4936,13 +8006,19 @@ class OAuth2AuthenticationSettingsContract(Model): 'scope': {'key': 'scope', 'type': 'str'}, } - def __init__(self, *, authorization_server_id: str=None, scope: str=None, **kwargs) -> None: + def __init__( + self, + *, + authorization_server_id: Optional[str] = None, + scope: Optional[str] = None, + **kwargs + ): super(OAuth2AuthenticationSettingsContract, self).__init__(**kwargs) self.authorization_server_id = authorization_server_id self.scope = scope -class OpenIdAuthenticationSettingsContract(Model): +class OpenIdAuthenticationSettingsContract(msrest.serialization.Model): """API OAuth2 Authentication settings details. :param openid_provider_id: OAuth authorization server identifier. @@ -4957,19 +8033,48 @@ class OpenIdAuthenticationSettingsContract(Model): 'bearer_token_sending_methods': {'key': 'bearerTokenSendingMethods', 'type': '[str]'}, } - def __init__(self, *, openid_provider_id: str=None, bearer_token_sending_methods=None, **kwargs) -> None: + def __init__( + self, + *, + openid_provider_id: Optional[str] = None, + bearer_token_sending_methods: Optional[List[Union[str, "BearerTokenSendingMethods"]]] = None, + **kwargs + ): super(OpenIdAuthenticationSettingsContract, self).__init__(**kwargs) self.openid_provider_id = openid_provider_id self.bearer_token_sending_methods = bearer_token_sending_methods +class OpenIdConnectProviderCollection(msrest.serialization.Model): + """Paged OpenIdProviders list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OpenidConnectProviderContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OpenidConnectProviderContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OpenIdConnectProviderCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class OpenidConnectProviderContract(Resource): """OpenId Connect Provider details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -4977,17 +8082,15 @@ class OpenidConnectProviderContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. User-friendly OpenID Connect Provider name. + :param display_name: User-friendly OpenID Connect Provider name. :type display_name: str :param description: User-friendly description of OpenID Connect Provider. :type description: str - :param metadata_endpoint: Required. Metadata endpoint URI. + :param metadata_endpoint: Metadata endpoint URI. :type metadata_endpoint: str - :param client_id: Required. Client ID of developer console which is the - client application. + :param client_id: Client ID of developer console which is the client application. :type client_id: str - :param client_secret: Client Secret of developer console which is the - client application. + :param client_secret: Client Secret of developer console which is the client application. :type client_secret: str """ @@ -4995,9 +8098,7 @@ class OpenidConnectProviderContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 50}, - 'metadata_endpoint': {'required': True}, - 'client_id': {'required': True}, + 'display_name': {'max_length': 50, 'min_length': 0}, } _attribute_map = { @@ -5011,7 +8112,16 @@ class OpenidConnectProviderContract(Resource): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, display_name: str, metadata_endpoint: str, client_id: str, description: str=None, client_secret: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata_endpoint: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(OpenidConnectProviderContract, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -5020,7 +8130,7 @@ def __init__(self, *, display_name: str, metadata_endpoint: str, client_id: str, self.client_secret = client_secret -class OpenidConnectProviderUpdateContract(Model): +class OpenidConnectProviderUpdateContract(msrest.serialization.Model): """Parameters supplied to the Update OpenID Connect Provider operation. :param display_name: User-friendly OpenID Connect Provider name. @@ -5029,16 +8139,14 @@ class OpenidConnectProviderUpdateContract(Model): :type description: str :param metadata_endpoint: Metadata endpoint URI. :type metadata_endpoint: str - :param client_id: Client ID of developer console which is the client - application. + :param client_id: Client ID of developer console which is the client application. :type client_id: str - :param client_secret: Client Secret of developer console which is the - client application. + :param client_secret: Client Secret of developer console which is the client application. :type client_secret: str """ _validation = { - 'display_name': {'max_length': 50}, + 'display_name': {'max_length': 50, 'min_length': 0}, } _attribute_map = { @@ -5049,7 +8157,16 @@ class OpenidConnectProviderUpdateContract(Model): 'client_secret': {'key': 'properties.clientSecret', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, description: str=None, metadata_endpoint: str=None, client_id: str=None, client_secret: str=None, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + metadata_endpoint: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + **kwargs + ): super(OpenidConnectProviderUpdateContract, self).__init__(**kwargs) self.display_name = display_name self.description = description @@ -5058,10 +8175,10 @@ def __init__(self, *, display_name: str=None, description: str=None, metadata_en self.client_secret = client_secret -class Operation(Model): +class Operation(msrest.serialization.Model): """REST API operation. - :param name: Operation name: {provider}/{resource}/{operation} + :param name: Operation name: {provider}/{resource}/{operation}. :type name: str :param display: The object that describes the operation. :type display: ~azure.mgmt.apimanagement.models.OperationDisplay @@ -5078,7 +8195,15 @@ class Operation(Model): 'properties': {'key': 'properties', 'type': 'object'}, } - def __init__(self, *, name: str=None, display=None, origin: str=None, properties=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + properties: Optional[object] = None, + **kwargs + ): super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -5086,13 +8211,40 @@ def __init__(self, *, name: str=None, display=None, origin: str=None, properties self.properties = properties +class OperationCollection(msrest.serialization.Model): + """Paged Operation list representation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Page values. + :vartype value: list[~azure.mgmt.apimanagement.models.OperationContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class OperationContract(Resource): """Api Operation details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5101,25 +8253,22 @@ class OperationContract(Resource): :ivar type: Resource type for API Management resource. :vartype type: str :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str - :param display_name: Required. Operation Name. + :param display_name: Operation Name. :type display_name: str - :param method: Required. A Valid HTTP Operation Method. Typical Http - Methods like GET, PUT, POST but not limited by only them. + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :type method: str - :param url_template: Required. Relative URL template identifying the - target resource for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :type url_template: str """ @@ -5127,10 +8276,9 @@ class OperationContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'description': {'max_length': 1000}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, - 'method': {'required': True}, - 'url_template': {'required': True, 'max_length': 1000, 'min_length': 1}, + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'url_template': {'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -5147,7 +8295,19 @@ class OperationContract(Resource): 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, } - def __init__(self, *, display_name: str, method: str, url_template: str, template_parameters=None, description: str=None, request=None, responses=None, policies: str=None, **kwargs) -> None: + def __init__( + self, + *, + template_parameters: Optional[List["ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["RequestContract"] = None, + responses: Optional[List["ResponseContract"]] = None, + policies: Optional[str] = None, + display_name: Optional[str] = None, + method: Optional[str] = None, + url_template: Optional[str] = None, + **kwargs + ): super(OperationContract, self).__init__(**kwargs) self.template_parameters = template_parameters self.description = description @@ -5159,54 +8319,81 @@ def __init__(self, *, display_name: str, method: str, url_template: str, templat self.url_template = url_template -class OperationDisplay(Model): - """The object that describes the operation. +class OperationEntityBaseContract(msrest.serialization.Model): + """Api Operation Entity Base Contract details. - :param provider: Friendly name of the resource provider - :type provider: str - :param operation: Operation type: read, write, delete, listKeys/action, - etc. - :type operation: str - :param resource: Resource type on which the operation is performed. - :type resource: str - :param description: Friendly name of the operation + :param template_parameters: Collection of URL template parameters. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str + :param request: An entity containing request details. + :type request: ~azure.mgmt.apimanagement.models.RequestContract + :param responses: Array of Operation responses. + :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :param policies: Operation Policies. + :type policies: str """ + _validation = { + 'description': {'max_length': 1000, 'min_length': 0}, + } + _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, + 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, 'description': {'key': 'description', 'type': 'str'}, + 'request': {'key': 'request', 'type': 'RequestContract'}, + 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, + 'policies': {'key': 'policies', 'type': 'str'}, } - def __init__(self, *, provider: str=None, operation: str=None, resource: str=None, description: str=None, **kwargs) -> None: - super(OperationDisplay, self).__init__(**kwargs) - self.provider = provider - self.operation = operation - self.resource = resource + def __init__( + self, + *, + template_parameters: Optional[List["ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["RequestContract"] = None, + responses: Optional[List["ResponseContract"]] = None, + policies: Optional[str] = None, + **kwargs + ): + super(OperationEntityBaseContract, self).__init__(**kwargs) + self.template_parameters = template_parameters self.description = description + self.request = request + self.responses = responses + self.policies = policies -class OperationEntityBaseContract(Model): - """Api Operation Entity Base Contract details. +class OperationContractProperties(OperationEntityBaseContract): + """Operation Contract Properties. + + All required parameters must be populated in order to send to Azure. :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str + :param display_name: Required. Operation Name. + :type display_name: str + :param method: Required. A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, + POST but not limited by only them. + :type method: str + :param url_template: Required. Relative URL template identifying the target resource for this + operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :type url_template: str """ _validation = { - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'method': {'required': True}, + 'url_template': {'required': True, 'max_length': 1000, 'min_length': 1}, } _attribute_map = { @@ -5215,46 +8402,116 @@ class OperationEntityBaseContract(Model): 'request': {'key': 'request', 'type': 'RequestContract'}, 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, 'policies': {'key': 'policies', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'method': {'key': 'method', 'type': 'str'}, + 'url_template': {'key': 'urlTemplate', 'type': 'str'}, } - def __init__(self, *, template_parameters=None, description: str=None, request=None, responses=None, policies: str=None, **kwargs) -> None: - super(OperationEntityBaseContract, self).__init__(**kwargs) - self.template_parameters = template_parameters + def __init__( + self, + *, + display_name: str, + method: str, + url_template: str, + template_parameters: Optional[List["ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["RequestContract"] = None, + responses: Optional[List["ResponseContract"]] = None, + policies: Optional[str] = None, + **kwargs + ): + super(OperationContractProperties, self).__init__(template_parameters=template_parameters, description=description, request=request, responses=responses, policies=policies, **kwargs) + self.display_name = display_name + self.method = method + self.url_template = url_template + + +class OperationDisplay(msrest.serialization.Model): + """The object that describes the operation. + + :param provider: Friendly name of the resource provider. + :type provider: str + :param operation: Operation type: read, write, delete, listKeys/action, etc. + :type operation: str + :param resource: Resource type on which the operation is performed. + :type resource: str + :param description: Friendly name of the operation. + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + operation: Optional[str] = None, + resource: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.operation = operation + self.resource = resource self.description = description - self.request = request - self.responses = responses - self.policies = policies -class OperationResultContract(Model): +class OperationListResult(msrest.serialization.Model): + """Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. + + :param value: List of operations supported by the resource provider. + :type value: list[~azure.mgmt.apimanagement.models.Operation] + :param next_link: URL to get the next set of operation list results if there are any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationResultContract(msrest.serialization.Model): """Operation Result. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :param id: Operation result identifier. :type id: str - :param status: Status of an async operation. Possible values include: - 'Started', 'InProgress', 'Succeeded', 'Failed' + :param status: Status of an async operation. Possible values include: "Started", "InProgress", + "Succeeded", "Failed". :type status: str or ~azure.mgmt.apimanagement.models.AsyncOperationStatus - :param started: Start time of an async operation. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type started: datetime - :param updated: Last update time of an async operation. The date conforms - to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO - 8601 standard. - :type updated: datetime + :param started: Start time of an async operation. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type started: ~datetime.datetime + :param updated: Last update time of an async operation. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type updated: ~datetime.datetime :param result_info: Optional result info. :type result_info: str - :param error: Error Body Contract + :param error: Error Body Contract. :type error: ~azure.mgmt.apimanagement.models.ErrorResponseBody - :ivar action_log: This property if only provided as part of the - TenantConfiguration_Validate operation. It contains the log the entities - which will be updated/created/deleted as part of the - TenantConfiguration_Deploy operation. - :vartype action_log: - list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] + :ivar action_log: This property if only provided as part of the TenantConfiguration_Validate + operation. It contains the log the entities which will be updated/created/deleted as part of + the TenantConfiguration_Deploy operation. + :vartype action_log: list[~azure.mgmt.apimanagement.models.OperationResultLogItemContract] """ _validation = { @@ -5263,7 +8520,7 @@ class OperationResultContract(Model): _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'AsyncOperationStatus'}, + 'status': {'key': 'status', 'type': 'str'}, 'started': {'key': 'started', 'type': 'iso-8601'}, 'updated': {'key': 'updated', 'type': 'iso-8601'}, 'result_info': {'key': 'resultInfo', 'type': 'str'}, @@ -5271,7 +8528,17 @@ class OperationResultContract(Model): 'action_log': {'key': 'actionLog', 'type': '[OperationResultLogItemContract]'}, } - def __init__(self, *, id: str=None, status=None, started=None, updated=None, result_info: str=None, error=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + status: Optional[Union[str, "AsyncOperationStatus"]] = None, + started: Optional[datetime.datetime] = None, + updated: Optional[datetime.datetime] = None, + result_info: Optional[str] = None, + error: Optional["ErrorResponseBody"] = None, + **kwargs + ): super(OperationResultContract, self).__init__(**kwargs) self.id = id self.status = status @@ -5282,7 +8549,7 @@ def __init__(self, *, id: str=None, status=None, started=None, updated=None, res self.action_log = None -class OperationResultLogItemContract(Model): +class OperationResultLogItemContract(msrest.serialization.Model): """Log of the entity being created, updated or deleted. :param object_type: The type of entity contract. @@ -5299,18 +8566,24 @@ class OperationResultLogItemContract(Model): 'object_key': {'key': 'objectKey', 'type': 'str'}, } - def __init__(self, *, object_type: str=None, action: str=None, object_key: str=None, **kwargs) -> None: + def __init__( + self, + *, + object_type: Optional[str] = None, + action: Optional[str] = None, + object_key: Optional[str] = None, + **kwargs + ): super(OperationResultLogItemContract, self).__init__(**kwargs) self.object_type = object_type self.action = action self.object_key = object_key -class OperationTagResourceContractProperties(Model): +class OperationTagResourceContractProperties(msrest.serialization.Model): """Operation Entity contract Properties. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :param id: Identifier of the operation in form /operations/{operationId}. :type id: str @@ -5324,12 +8597,11 @@ class OperationTagResourceContractProperties(Model): :vartype api_version: str :ivar description: Operation Description. :vartype description: str - :ivar method: A Valid HTTP Operation Method. Typical Http Methods like - GET, PUT, POST but not limited by only them. + :ivar method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :vartype method: str - :ivar url_template: Relative URL template identifying the target resource - for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :ivar url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :vartype url_template: str """ @@ -5354,7 +8626,12 @@ class OperationTagResourceContractProperties(Model): 'url_template': {'key': 'urlTemplate', 'type': 'str'}, } - def __init__(self, *, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): super(OperationTagResourceContractProperties, self).__init__(**kwargs) self.id = id self.name = None @@ -5366,34 +8643,31 @@ def __init__(self, *, id: str=None, **kwargs) -> None: self.url_template = None -class OperationUpdateContract(Model): +class OperationUpdateContract(msrest.serialization.Model): """Api Operation Update Contract details. :param template_parameters: Collection of URL template parameters. - :type template_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] - :param description: Description of the operation. May include HTML - formatting tags. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. :type description: str :param request: An entity containing request details. :type request: ~azure.mgmt.apimanagement.models.RequestContract :param responses: Array of Operation responses. :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] - :param policies: Operation Policies + :param policies: Operation Policies. :type policies: str :param display_name: Operation Name. :type display_name: str - :param method: A Valid HTTP Operation Method. Typical Http Methods like - GET, PUT, POST but not limited by only them. + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. :type method: str - :param url_template: Relative URL template identifying the target resource - for this operation. May include parameters. Example: - /customers/{cid}/orders/{oid}/?date={date} + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. :type url_template: str """ _validation = { - 'description': {'max_length': 1000}, + 'description': {'max_length': 1000, 'min_length': 0}, 'display_name': {'max_length': 300, 'min_length': 1}, 'url_template': {'max_length': 1000, 'min_length': 1}, } @@ -5409,7 +8683,19 @@ class OperationUpdateContract(Model): 'url_template': {'key': 'properties.urlTemplate', 'type': 'str'}, } - def __init__(self, *, template_parameters=None, description: str=None, request=None, responses=None, policies: str=None, display_name: str=None, method: str=None, url_template: str=None, **kwargs) -> None: + def __init__( + self, + *, + template_parameters: Optional[List["ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["RequestContract"] = None, + responses: Optional[List["ResponseContract"]] = None, + policies: Optional[str] = None, + display_name: Optional[str] = None, + method: Optional[str] = None, + url_template: Optional[str] = None, + **kwargs + ): super(OperationUpdateContract, self).__init__(**kwargs) self.template_parameters = template_parameters self.description = description @@ -5421,7 +8707,66 @@ def __init__(self, *, template_parameters=None, description: str=None, request=N self.url_template = url_template -class ParameterContract(Model): +class OperationUpdateContractProperties(OperationEntityBaseContract): + """Operation Update Contract Properties. + + :param template_parameters: Collection of URL template parameters. + :type template_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] + :param description: Description of the operation. May include HTML formatting tags. + :type description: str + :param request: An entity containing request details. + :type request: ~azure.mgmt.apimanagement.models.RequestContract + :param responses: Array of Operation responses. + :type responses: list[~azure.mgmt.apimanagement.models.ResponseContract] + :param policies: Operation Policies. + :type policies: str + :param display_name: Operation Name. + :type display_name: str + :param method: A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not + limited by only them. + :type method: str + :param url_template: Relative URL template identifying the target resource for this operation. + May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date}. + :type url_template: str + """ + + _validation = { + 'description': {'max_length': 1000, 'min_length': 0}, + 'display_name': {'max_length': 300, 'min_length': 1}, + 'url_template': {'max_length': 1000, 'min_length': 1}, + } + + _attribute_map = { + 'template_parameters': {'key': 'templateParameters', 'type': '[ParameterContract]'}, + 'description': {'key': 'description', 'type': 'str'}, + 'request': {'key': 'request', 'type': 'RequestContract'}, + 'responses': {'key': 'responses', 'type': '[ResponseContract]'}, + 'policies': {'key': 'policies', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'method': {'key': 'method', 'type': 'str'}, + 'url_template': {'key': 'urlTemplate', 'type': 'str'}, + } + + def __init__( + self, + *, + template_parameters: Optional[List["ParameterContract"]] = None, + description: Optional[str] = None, + request: Optional["RequestContract"] = None, + responses: Optional[List["ResponseContract"]] = None, + policies: Optional[str] = None, + display_name: Optional[str] = None, + method: Optional[str] = None, + url_template: Optional[str] = None, + **kwargs + ): + super(OperationUpdateContractProperties, self).__init__(template_parameters=template_parameters, description=description, request=request, responses=responses, policies=policies, **kwargs) + self.display_name = display_name + self.method = method + self.url_template = url_template + + +class ParameterContract(msrest.serialization.Model): """Operation parameters details. All required parameters must be populated in order to send to Azure. @@ -5454,7 +8799,17 @@ class ParameterContract(Model): 'values': {'key': 'values', 'type': '[str]'}, } - def __init__(self, *, name: str, type: str, description: str=None, default_value: str=None, required: bool=None, values=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + type: str, + description: Optional[str] = None, + default_value: Optional[str] = None, + required: Optional[bool] = None, + values: Optional[List[str]] = None, + **kwargs + ): super(ParameterContract, self).__init__(**kwargs) self.name = name self.description = description @@ -5464,7 +8819,7 @@ def __init__(self, *, name: str, type: str, description: str=None, default_value self.values = values -class PipelineDiagnosticSettings(Model): +class PipelineDiagnosticSettings(msrest.serialization.Model): """Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. :param request: Diagnostic settings for request. @@ -5478,13 +8833,19 @@ class PipelineDiagnosticSettings(Model): 'response': {'key': 'response', 'type': 'HttpMessageDiagnostic'}, } - def __init__(self, *, request=None, response=None, **kwargs) -> None: + def __init__( + self, + *, + request: Optional["HttpMessageDiagnostic"] = None, + response: Optional["HttpMessageDiagnostic"] = None, + **kwargs + ): super(PipelineDiagnosticSettings, self).__init__(**kwargs) self.request = request self.response = response -class PolicyCollection(Model): +class PolicyCollection(msrest.serialization.Model): """The response of the list policy operation. :param value: Policy Contract value. @@ -5498,7 +8859,13 @@ class PolicyCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["PolicyContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(PolicyCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -5507,10 +8874,7 @@ def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: class PolicyContract(Resource): """Policy Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5518,10 +8882,10 @@ class PolicyContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param value: Required. Contents of the Policy as defined by the format. + :param value: Contents of the Policy as defined by the format. :type value: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link'. Default value: "xml" . + :param format: Format of the policyContent. Possible values include: "xml", "xml-link", + "rawxml", "rawxml-link". Default value: "xml". :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat """ @@ -5529,7 +8893,6 @@ class PolicyContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'value': {'required': True}, } _attribute_map = { @@ -5540,18 +8903,23 @@ class PolicyContract(Resource): 'format': {'key': 'properties.format', 'type': 'str'}, } - def __init__(self, *, value: str, format="xml", **kwargs) -> None: + def __init__( + self, + *, + value: Optional[str] = None, + format: Optional[Union[str, "PolicyContentFormat"]] = "xml", + **kwargs + ): super(PolicyContract, self).__init__(**kwargs) self.value = value self.format = format -class PolicyDescriptionCollection(Model): +class PolicyDescriptionCollection(msrest.serialization.Model): """Descriptions of APIM policies. :param value: Descriptions of APIM policies. - :type value: - list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] + :type value: list[~azure.mgmt.apimanagement.models.PolicyDescriptionContract] :param count: Total record count number. :type count: long """ @@ -5561,7 +8929,13 @@ class PolicyDescriptionCollection(Model): 'count': {'key': 'count', 'type': 'long'}, } - def __init__(self, *, value=None, count: int=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["PolicyDescriptionContract"]] = None, + count: Optional[int] = None, + **kwargs + ): super(PolicyDescriptionCollection, self).__init__(**kwargs) self.value = value self.count = count @@ -5570,8 +8944,7 @@ def __init__(self, *, value=None, count: int=None, **kwargs) -> None: class PolicyDescriptionContract(Resource): """Policy description details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5601,7 +8974,10 @@ class PolicyDescriptionContract(Resource): 'scope': {'key': 'properties.scope', 'type': 'int'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(PolicyDescriptionContract, self).__init__(**kwargs) self.description = None self.scope = None @@ -5610,8 +8986,7 @@ def __init__(self, **kwargs) -> None: class PortalDelegationSettings(Resource): """Delegation settings for a developer portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5621,12 +8996,11 @@ class PortalDelegationSettings(Resource): :vartype type: str :param url: A delegation Url. :type url: str - :param validation_key: A base64-encoded validation key to validate, that a - request is coming from Azure API Management. + :param validation_key: A base64-encoded validation key to validate, that a request is coming + from Azure API Management. :type validation_key: str :param subscriptions: Subscriptions delegation settings. - :type subscriptions: - ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties + :type subscriptions: ~azure.mgmt.apimanagement.models.SubscriptionsDelegationSettingsProperties :param user_registration: User registration delegation settings. :type user_registration: ~azure.mgmt.apimanagement.models.RegistrationDelegationSettingsProperties @@ -5648,7 +9022,15 @@ class PortalDelegationSettings(Resource): 'user_registration': {'key': 'properties.userRegistration', 'type': 'RegistrationDelegationSettingsProperties'}, } - def __init__(self, *, url: str=None, validation_key: str=None, subscriptions=None, user_registration=None, **kwargs) -> None: + def __init__( + self, + *, + url: Optional[str] = None, + validation_key: Optional[str] = None, + subscriptions: Optional["SubscriptionsDelegationSettingsProperties"] = None, + user_registration: Optional["RegistrationDelegationSettingsProperties"] = None, + **kwargs + ): super(PortalDelegationSettings, self).__init__(**kwargs) self.url = url self.validation_key = validation_key @@ -5656,11 +9038,10 @@ def __init__(self, *, url: str=None, validation_key: str=None, subscriptions=Non self.user_registration = user_registration -class PortalSettingValidationKeyContract(Model): +class PortalSettingValidationKeyContract(msrest.serialization.Model): """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. - :param validation_key: This is secret value of the validation key in - portal settings. + :param validation_key: This is secret value of the validation key in portal settings. :type validation_key: str """ @@ -5668,7 +9049,12 @@ class PortalSettingValidationKeyContract(Model): 'validation_key': {'key': 'validationKey', 'type': 'str'}, } - def __init__(self, *, validation_key: str=None, **kwargs) -> None: + def __init__( + self, + *, + validation_key: Optional[str] = None, + **kwargs + ): super(PortalSettingValidationKeyContract, self).__init__(**kwargs) self.validation_key = validation_key @@ -5676,8 +9062,7 @@ def __init__(self, *, validation_key: str=None, **kwargs) -> None: class PortalSigninSettings(Resource): """Sign-In settings for the Developer Portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5702,7 +9087,12 @@ class PortalSigninSettings(Resource): 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } - def __init__(self, *, enabled: bool=None, **kwargs) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): super(PortalSigninSettings, self).__init__(**kwargs) self.enabled = enabled @@ -5710,8 +9100,7 @@ def __init__(self, *, enabled: bool=None, **kwargs) -> None: class PortalSignupSettings(Resource): """Sign-Up settings for a developer portal. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5722,8 +9111,7 @@ class PortalSignupSettings(Resource): :param enabled: Allow users to sign up on a developer portal. :type enabled: bool :param terms_of_service: Terms of service contract properties. - :type terms_of_service: - ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties """ _validation = { @@ -5740,19 +9128,48 @@ class PortalSignupSettings(Resource): 'terms_of_service': {'key': 'properties.termsOfService', 'type': 'TermsOfServiceProperties'}, } - def __init__(self, *, enabled: bool=None, terms_of_service=None, **kwargs) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + terms_of_service: Optional["TermsOfServiceProperties"] = None, + **kwargs + ): super(PortalSignupSettings, self).__init__(**kwargs) self.enabled = enabled self.terms_of_service = terms_of_service +class ProductCollection(msrest.serialization.Model): + """Paged Products list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ProductContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ProductContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ProductContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ProductCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class ProductContract(Resource): """Product details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -5762,36 +9179,31 @@ class ProductContract(Resource): :vartype type: str :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param display_name: Required. Product name. + :param display_name: Product name. :type display_name: str """ @@ -5800,7 +9212,7 @@ class ProductContract(Resource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'description': {'max_length': 1000, 'min_length': 1}, - 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, } _attribute_map = { @@ -5812,11 +9224,22 @@ class ProductContract(Resource): 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'ProductState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, *, display_name: str, description: str=None, terms: str=None, subscription_required: bool=None, approval_required: bool=None, subscriptions_limit: int=None, state=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + display_name: Optional[str] = None, + **kwargs + ): super(ProductContract, self).__init__(**kwargs) self.description = description self.terms = terms @@ -5827,39 +9250,34 @@ def __init__(self, *, display_name: str, description: str=None, terms: str=None, self.display_name = display_name -class ProductEntityBaseParameters(Model): +class ProductEntityBaseParameters(msrest.serialization.Model): """Product Entity Base Parameters. :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState """ @@ -5873,10 +9291,20 @@ class ProductEntityBaseParameters(Model): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'ProductState'}, + 'state': {'key': 'state', 'type': 'str'}, } - def __init__(self, *, description: str=None, terms: str=None, subscription_required: bool=None, approval_required: bool=None, subscriptions_limit: int=None, state=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + **kwargs + ): super(ProductEntityBaseParameters, self).__init__(**kwargs) self.description = description self.terms = terms @@ -5886,6 +9314,72 @@ def __init__(self, *, description: str=None, terms: str=None, subscription_requi self.state = state +class ProductContractProperties(ProductEntityBaseParameters): + """Product profile. + + All required parameters must be populated in order to send to Azure. + + :param description: Product description. May include HTML formatting tags. + :type description: str + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :type terms: str + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :type subscription_required: bool + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :type approval_required: bool + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :type subscriptions_limit: int + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". + :type state: str or ~azure.mgmt.apimanagement.models.ProductState + :param display_name: Required. Product name. + :type display_name: str + """ + + _validation = { + 'description': {'max_length': 1000, 'min_length': 1}, + 'display_name': {'required': True, 'max_length': 300, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'terms': {'key': 'terms', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, + 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, + 'state': {'key': 'state', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: str, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + **kwargs + ): + super(ProductContractProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) + self.display_name = display_name + + class ProductTagResourceContractProperties(ProductEntityBaseParameters): """Product profile. @@ -5893,36 +9387,31 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState - :param id: Identifier of the product in the form of /products/{productId} + :param id: Identifier of the product in the form of /products/{productId}. :type id: str :param name: Required. Product name. :type name: str @@ -5939,50 +9428,57 @@ class ProductTagResourceContractProperties(ProductEntityBaseParameters): 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'ProductState'}, + 'state': {'key': 'state', 'type': 'str'}, 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, name: str, description: str=None, terms: str=None, subscription_required: bool=None, approval_required: bool=None, subscriptions_limit: int=None, state=None, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + id: Optional[str] = None, + **kwargs + ): super(ProductTagResourceContractProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) self.id = id self.name = name -class ProductUpdateParameters(Model): +class ProductUpdateParameters(msrest.serialization.Model): """Product Update parameters. :param description: Product description. May include HTML formatting tags. :type description: str - :param terms: Product terms of use. Developers trying to subscribe to the - product will be presented and required to accept these terms before they - can complete the subscription process. + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. :type terms: str - :param subscription_required: Whether a product subscription is required - for accessing APIs included in this product. If true, the product is - referred to as "protected" and a valid subscription key is required for a - request to an API included in the product to succeed. If false, the - product is referred to as "open" and requests to an API included in the - product can be made without a subscription key. If property is omitted - when creating a new product it's value is assumed to be true. + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. :type subscription_required: bool - :param approval_required: whether subscription approval is required. If - false, new subscriptions will be approved automatically enabling - developers to call the product’s APIs immediately after subscribing. If - true, administrators must manually approve the subscription before the - developer can any of the product’s APIs. Can be present only if - subscriptionRequired property is present and has a value of false. + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. :type approval_required: bool - :param subscriptions_limit: Whether the number of subscriptions a user can - have to this product at the same time. Set to null or omit to allow - unlimited per user subscriptions. Can be present only if - subscriptionRequired property is present and has a value of false. + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. :type subscriptions_limit: int - :param state: whether product is published or not. Published products are - discoverable by users of developer portal. Non published products are - visible only to administrators. Default state of Product is notPublished. - Possible values include: 'notPublished', 'published' + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". :type state: str or ~azure.mgmt.apimanagement.models.ProductState :param display_name: Product name. :type display_name: str @@ -5999,11 +9495,22 @@ class ProductUpdateParameters(Model): 'subscription_required': {'key': 'properties.subscriptionRequired', 'type': 'bool'}, 'approval_required': {'key': 'properties.approvalRequired', 'type': 'bool'}, 'subscriptions_limit': {'key': 'properties.subscriptionsLimit', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'ProductState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, *, description: str=None, terms: str=None, subscription_required: bool=None, approval_required: bool=None, subscriptions_limit: int=None, state=None, display_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + display_name: Optional[str] = None, + **kwargs + ): super(ProductUpdateParameters, self).__init__(**kwargs) self.description = description self.terms = terms @@ -6014,23 +9521,71 @@ def __init__(self, *, description: str=None, terms: str=None, subscription_requi self.display_name = display_name -class PropertyValueContract(Model): - """Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +class ProductUpdateProperties(ProductEntityBaseParameters): + """Parameters supplied to the Update Product operation. - :param value: This is secret value of the NamedValue entity. - :type value: str + :param description: Product description. May include HTML formatting tags. + :type description: str + :param terms: Product terms of use. Developers trying to subscribe to the product will be + presented and required to accept these terms before they can complete the subscription process. + :type terms: str + :param subscription_required: Whether a product subscription is required for accessing APIs + included in this product. If true, the product is referred to as "protected" and a valid + subscription key is required for a request to an API included in the product to succeed. If + false, the product is referred to as "open" and requests to an API included in the product can + be made without a subscription key. If property is omitted when creating a new product it's + value is assumed to be true. + :type subscription_required: bool + :param approval_required: whether subscription approval is required. If false, new + subscriptions will be approved automatically enabling developers to call the product’s APIs + immediately after subscribing. If true, administrators must manually approve the subscription + before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + property is present and has a value of false. + :type approval_required: bool + :param subscriptions_limit: Whether the number of subscriptions a user can have to this product + at the same time. Set to null or omit to allow unlimited per user subscriptions. Can be present + only if subscriptionRequired property is present and has a value of false. + :type subscriptions_limit: int + :param state: whether product is published or not. Published products are discoverable by users + of developer portal. Non published products are visible only to administrators. Default state + of Product is notPublished. Possible values include: "notPublished", "published". + :type state: str or ~azure.mgmt.apimanagement.models.ProductState + :param display_name: Product name. + :type display_name: str """ + _validation = { + 'description': {'max_length': 1000, 'min_length': 1}, + 'display_name': {'max_length': 300, 'min_length': 1}, + } + _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'terms': {'key': 'terms', 'type': 'str'}, + 'subscription_required': {'key': 'subscriptionRequired', 'type': 'bool'}, + 'approval_required': {'key': 'approvalRequired', 'type': 'bool'}, + 'subscriptions_limit': {'key': 'subscriptionsLimit', 'type': 'int'}, + 'state': {'key': 'state', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, } - def __init__(self, *, value: str=None, **kwargs) -> None: - super(PropertyValueContract, self).__init__(**kwargs) - self.value = value + def __init__( + self, + *, + description: Optional[str] = None, + terms: Optional[str] = None, + subscription_required: Optional[bool] = None, + approval_required: Optional[bool] = None, + subscriptions_limit: Optional[int] = None, + state: Optional[Union[str, "ProductState"]] = None, + display_name: Optional[str] = None, + **kwargs + ): + super(ProductUpdateProperties, self).__init__(description=description, terms=terms, subscription_required=subscription_required, approval_required=approval_required, subscriptions_limit=subscriptions_limit, state=state, **kwargs) + self.display_name = display_name -class QuotaCounterCollection(Model): +class QuotaCounterCollection(msrest.serialization.Model): """Paged Quota Counter list representation. :param value: Quota counter values. @@ -6047,35 +9602,38 @@ class QuotaCounterCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, value=None, count: int=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["QuotaCounterContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): super(QuotaCounterCollection, self).__init__(**kwargs) self.value = value self.count = count self.next_link = next_link -class QuotaCounterContract(Model): +class QuotaCounterContract(msrest.serialization.Model): """Quota counter details. All required parameters must be populated in order to send to Azure. - :param counter_key: Required. The Key value of the Counter. Must not be - empty. + :param counter_key: Required. The Key value of the Counter. Must not be empty. :type counter_key: str - :param period_key: Required. Identifier of the Period for which the - counter was collected. Must not be empty. + :param period_key: Required. Identifier of the Period for which the counter was collected. Must + not be empty. :type period_key: str - :param period_start_time: Required. The date of the start of Counter - Period. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type period_start_time: datetime - :param period_end_time: Required. The date of the end of Counter Period. - The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as - specified by the ISO 8601 standard. - :type period_end_time: datetime - :param value: Quota Value Properties - :type value: - ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties + :param period_start_time: Required. The date of the start of Counter Period. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type period_start_time: ~datetime.datetime + :param period_end_time: Required. The date of the end of Counter Period. The date conforms to + the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type period_end_time: ~datetime.datetime + :param value: Quota Value Properties. + :type value: ~azure.mgmt.apimanagement.models.QuotaCounterValueContractProperties """ _validation = { @@ -6093,7 +9651,16 @@ class QuotaCounterContract(Model): 'value': {'key': 'value', 'type': 'QuotaCounterValueContractProperties'}, } - def __init__(self, *, counter_key: str, period_key: str, period_start_time, period_end_time, value=None, **kwargs) -> None: + def __init__( + self, + *, + counter_key: str, + period_key: str, + period_start_time: datetime.datetime, + period_end_time: datetime.datetime, + value: Optional["QuotaCounterValueContractProperties"] = None, + **kwargs + ): super(QuotaCounterContract, self).__init__(**kwargs) self.counter_key = counter_key self.period_key = period_key @@ -6102,7 +9669,7 @@ def __init__(self, *, counter_key: str, period_key: str, period_start_time, peri self.value = value -class QuotaCounterValueContract(Model): +class QuotaCounterValueContract(msrest.serialization.Model): """Quota counter value details. :param calls_count: Number of times Counter was called. @@ -6116,13 +9683,19 @@ class QuotaCounterValueContract(Model): 'kb_transferred': {'key': 'value.kbTransferred', 'type': 'float'}, } - def __init__(self, *, calls_count: int=None, kb_transferred: float=None, **kwargs) -> None: + def __init__( + self, + *, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + **kwargs + ): super(QuotaCounterValueContract, self).__init__(**kwargs) self.calls_count = calls_count self.kb_transferred = kb_transferred -class QuotaCounterValueContractProperties(Model): +class QuotaCounterValueContractProperties(msrest.serialization.Model): """Quota counter value details. :param calls_count: Number of times Counter was called. @@ -6136,13 +9709,45 @@ class QuotaCounterValueContractProperties(Model): 'kb_transferred': {'key': 'kbTransferred', 'type': 'float'}, } - def __init__(self, *, calls_count: int=None, kb_transferred: float=None, **kwargs) -> None: + def __init__( + self, + *, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + **kwargs + ): super(QuotaCounterValueContractProperties, self).__init__(**kwargs) self.calls_count = calls_count self.kb_transferred = kb_transferred -class RecipientEmailCollection(Model): +class QuotaCounterValueUpdateContract(msrest.serialization.Model): + """Quota counter value details. + + :param calls_count: Number of times Counter was called. + :type calls_count: int + :param kb_transferred: Data Transferred in KiloBytes. + :type kb_transferred: float + """ + + _attribute_map = { + 'calls_count': {'key': 'properties.callsCount', 'type': 'int'}, + 'kb_transferred': {'key': 'properties.kbTransferred', 'type': 'float'}, + } + + def __init__( + self, + *, + calls_count: Optional[int] = None, + kb_transferred: Optional[float] = None, + **kwargs + ): + super(QuotaCounterValueUpdateContract, self).__init__(**kwargs) + self.calls_count = calls_count + self.kb_transferred = kb_transferred + + +class RecipientEmailCollection(msrest.serialization.Model): """Paged Recipient User list representation. :param value: Page values. @@ -6156,7 +9761,13 @@ class RecipientEmailCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["RecipientEmailContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(RecipientEmailCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6165,8 +9776,7 @@ def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: class RecipientEmailContract(Resource): """Recipient Email details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6191,12 +9801,17 @@ class RecipientEmailContract(Resource): 'email': {'key': 'properties.email', 'type': 'str'}, } - def __init__(self, *, email: str=None, **kwargs) -> None: + def __init__( + self, + *, + email: Optional[str] = None, + **kwargs + ): super(RecipientEmailContract, self).__init__(**kwargs) self.email = email -class RecipientsContractProperties(Model): +class RecipientsContractProperties(msrest.serialization.Model): """Notification Parameter contract. :param emails: List of Emails subscribed for the notification. @@ -6210,13 +9825,19 @@ class RecipientsContractProperties(Model): 'users': {'key': 'users', 'type': '[str]'}, } - def __init__(self, *, emails=None, users=None, **kwargs) -> None: + def __init__( + self, + *, + emails: Optional[List[str]] = None, + users: Optional[List[str]] = None, + **kwargs + ): super(RecipientsContractProperties, self).__init__(**kwargs) self.emails = emails self.users = users -class RecipientUserCollection(Model): +class RecipientUserCollection(msrest.serialization.Model): """Paged Recipient User list representation. :param value: Page values. @@ -6230,7 +9851,13 @@ class RecipientUserCollection(Model): 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[List["RecipientUserContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): super(RecipientUserCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -6239,8 +9866,7 @@ def __init__(self, *, value=None, next_link: str=None, **kwargs) -> None: class RecipientUserContract(Resource): """Recipient User details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6265,16 +9891,20 @@ class RecipientUserContract(Resource): 'user_id': {'key': 'properties.userId', 'type': 'str'}, } - def __init__(self, *, user_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + user_id: Optional[str] = None, + **kwargs + ): super(RecipientUserContract, self).__init__(**kwargs) self.user_id = user_id -class RegionContract(Model): +class RegionContract(msrest.serialization.Model): """Region profile. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar name: Region name. :vartype name: str @@ -6294,14 +9924,51 @@ class RegionContract(Model): 'is_deleted': {'key': 'isDeleted', 'type': 'bool'}, } - def __init__(self, *, is_master_region: bool=None, is_deleted: bool=None, **kwargs) -> None: + def __init__( + self, + *, + is_master_region: Optional[bool] = None, + is_deleted: Optional[bool] = None, + **kwargs + ): super(RegionContract, self).__init__(**kwargs) self.name = None self.is_master_region = is_master_region self.is_deleted = is_deleted -class RegistrationDelegationSettingsProperties(Model): +class RegionListResult(msrest.serialization.Model): + """Lists Regions operation response details. + + :param value: Lists of Regions. + :type value: list[~azure.mgmt.apimanagement.models.RegionContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RegionContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RegionContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(RegionListResult, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class RegistrationDelegationSettingsProperties(msrest.serialization.Model): """User registration delegation settings properties. :param enabled: Enable or disable delegation for user registration. @@ -6312,26 +9979,60 @@ class RegistrationDelegationSettingsProperties(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, *, enabled: bool=None, **kwargs) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): super(RegistrationDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = enabled -class ReportRecordContract(Model): +class ReportCollection(msrest.serialization.Model): + """Paged Report records list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.ReportRecordContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReportRecordContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ReportRecordContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ReportCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link + + +class ReportRecordContract(msrest.serialization.Model): """Report data. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param name: Name depending on report endpoint specifies product, API, - operation or developer name. + :param name: Name depending on report endpoint specifies product, API, operation or developer + name. :type name: str - :param timestamp: Start of aggregation period. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type timestamp: datetime - :param interval: Length of aggregation period. Interval must be multiple - of 15 minutes and may not be zero. The value should be in ISO 8601 format + :param timestamp: Start of aggregation period. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type timestamp: ~datetime.datetime + :param interval: Length of aggregation period. Interval must be multiple of 15 minutes and may + not be zero. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations). :type interval: str :param country: Country to which this record data is related. @@ -6340,31 +10041,28 @@ class ReportRecordContract(Model): :type region: str :param zip: Zip code to which this record data is related. :type zip: str - :ivar user_id: User identifier path. /users/{userId} + :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str - :ivar product_id: Product identifier path. /products/{productId} + :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str - :param api_id: API identifier path. /apis/{apiId} + :param api_id: API identifier path. /apis/{apiId}. :type api_id: str - :param operation_id: Operation identifier path. - /apis/{apiId}/operations/{operationId} + :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. :type operation_id: str :param api_region: API region identifier. :type api_region: str - :param subscription_id: Subscription identifier path. - /subscriptions/{subscriptionId} + :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. :type subscription_id: str - :param call_count_success: Number of successful calls. This includes calls - returning HttpStatusCode <= 301 and HttpStatusCode.NotModified and - HttpStatusCode.TemporaryRedirect + :param call_count_success: Number of successful calls. This includes calls returning + HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect. :type call_count_success: int - :param call_count_blocked: Number of calls blocked due to invalid - credentials. This includes calls returning HttpStatusCode.Unauthorized and - HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests + :param call_count_blocked: Number of calls blocked due to invalid credentials. This includes + calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and + HttpStatusCode.TooManyRequests. :type call_count_blocked: int - :param call_count_failed: Number of calls failed due to proxy or backend - errors. This includes calls returning HttpStatusCode.BadRequest(400) and - any Code between HttpStatusCode.InternalServerError (500) and 600 + :param call_count_failed: Number of calls failed due to proxy or backend errors. This includes + calls returning HttpStatusCode.BadRequest(400) and any Code between + HttpStatusCode.InternalServerError (500) and 600. :type call_count_failed: int :param call_count_other: Number of other calls. :type call_count_other: int @@ -6372,8 +10070,7 @@ class ReportRecordContract(Model): :type call_count_total: int :param bandwidth: Bandwidth consumed. :type bandwidth: long - :param cache_hit_count: Number of times when content was served from cache - policy. + :param cache_hit_count: Number of times when content was served from cache policy. :type cache_hit_count: int :param cache_miss_count: Number of times content was fetched from backend. :type cache_miss_count: int @@ -6383,14 +10080,11 @@ class ReportRecordContract(Model): :type api_time_min: float :param api_time_max: Maximum time it took to process request. :type api_time_max: float - :param service_time_avg: Average time it took to process request on - backend. + :param service_time_avg: Average time it took to process request on backend. :type service_time_avg: float - :param service_time_min: Minimum time it took to process request on - backend. + :param service_time_min: Minimum time it took to process request on backend. :type service_time_min: float - :param service_time_max: Maximum time it took to process request on - backend. + :param service_time_max: Maximum time it took to process request on backend. :type service_time_max: float """ @@ -6428,7 +10122,35 @@ class ReportRecordContract(Model): 'service_time_max': {'key': 'serviceTimeMax', 'type': 'float'}, } - def __init__(self, *, name: str=None, timestamp=None, interval: str=None, country: str=None, region: str=None, zip: str=None, api_id: str=None, operation_id: str=None, api_region: str=None, subscription_id: str=None, call_count_success: int=None, call_count_blocked: int=None, call_count_failed: int=None, call_count_other: int=None, call_count_total: int=None, bandwidth: int=None, cache_hit_count: int=None, cache_miss_count: int=None, api_time_avg: float=None, api_time_min: float=None, api_time_max: float=None, service_time_avg: float=None, service_time_min: float=None, service_time_max: float=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + interval: Optional[str] = None, + country: Optional[str] = None, + region: Optional[str] = None, + zip: Optional[str] = None, + api_id: Optional[str] = None, + operation_id: Optional[str] = None, + api_region: Optional[str] = None, + subscription_id: Optional[str] = None, + call_count_success: Optional[int] = None, + call_count_blocked: Optional[int] = None, + call_count_failed: Optional[int] = None, + call_count_other: Optional[int] = None, + call_count_total: Optional[int] = None, + bandwidth: Optional[int] = None, + cache_hit_count: Optional[int] = None, + cache_miss_count: Optional[int] = None, + api_time_avg: Optional[float] = None, + api_time_min: Optional[float] = None, + api_time_max: Optional[float] = None, + service_time_avg: Optional[float] = None, + service_time_min: Optional[float] = None, + service_time_max: Optional[float] = None, + **kwargs + ): super(ReportRecordContract, self).__init__(**kwargs) self.name = name self.timestamp = timestamp @@ -6458,29 +10180,25 @@ def __init__(self, *, name: str=None, timestamp=None, interval: str=None, countr self.service_time_max = service_time_max -class RepresentationContract(Model): +class RepresentationContract(msrest.serialization.Model): """Operation request/response representation details. All required parameters must be populated in order to send to Azure. - :param content_type: Required. Specifies a registered or custom content - type for this representation, e.g. application/xml. + :param content_type: Required. Specifies a registered or custom content type for this + representation, e.g. application/xml. :type content_type: str :param sample: An example of the representation. :type sample: str - :param schema_id: Schema identifier. Applicable only if 'contentType' - value is neither 'application/x-www-form-urlencoded' nor - 'multipart/form-data'. + :param schema_id: Schema identifier. Applicable only if 'contentType' value is neither + 'application/x-www-form-urlencoded' nor 'multipart/form-data'. :type schema_id: str - :param type_name: Type name defined by the schema. Applicable only if - 'contentType' value is neither 'application/x-www-form-urlencoded' nor - 'multipart/form-data'. + :param type_name: Type name defined by the schema. Applicable only if 'contentType' value is + neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. :type type_name: str - :param form_parameters: Collection of form parameters. Required if - 'contentType' value is either 'application/x-www-form-urlencoded' or - 'multipart/form-data'.. - :type form_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] + :param form_parameters: Collection of form parameters. Required if 'contentType' value is + either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + :type form_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] """ _validation = { @@ -6495,7 +10213,16 @@ class RepresentationContract(Model): 'form_parameters': {'key': 'formParameters', 'type': '[ParameterContract]'}, } - def __init__(self, *, content_type: str, sample: str=None, schema_id: str=None, type_name: str=None, form_parameters=None, **kwargs) -> None: + def __init__( + self, + *, + content_type: str, + sample: Optional[str] = None, + schema_id: Optional[str] = None, + type_name: Optional[str] = None, + form_parameters: Optional[List["ParameterContract"]] = None, + **kwargs + ): super(RepresentationContract, self).__init__(**kwargs) self.content_type = content_type self.sample = sample @@ -6504,19 +10231,17 @@ def __init__(self, *, content_type: str, sample: str=None, schema_id: str=None, self.form_parameters = form_parameters -class RequestContract(Model): +class RequestContract(msrest.serialization.Model): """Operation request details. :param description: Operation request description. :type description: str :param query_parameters: Collection of operation request query parameters. - :type query_parameters: - list[~azure.mgmt.apimanagement.models.ParameterContract] + :type query_parameters: list[~azure.mgmt.apimanagement.models.ParameterContract] :param headers: Collection of operation request headers. :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] :param representations: Collection of operation request representations. - :type representations: - list[~azure.mgmt.apimanagement.models.RepresentationContract] + :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] """ _attribute_map = { @@ -6526,7 +10251,15 @@ class RequestContract(Model): 'representations': {'key': 'representations', 'type': '[RepresentationContract]'}, } - def __init__(self, *, description: str=None, query_parameters=None, headers=None, representations=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + query_parameters: Optional[List["ParameterContract"]] = None, + headers: Optional[List["ParameterContract"]] = None, + representations: Optional[List["RepresentationContract"]] = None, + **kwargs + ): super(RequestContract, self).__init__(**kwargs) self.description = description self.query_parameters = query_parameters @@ -6534,20 +10267,44 @@ def __init__(self, *, description: str=None, query_parameters=None, headers=None self.representations = representations -class RequestReportRecordContract(Model): +class RequestReportCollection(msrest.serialization.Model): + """Paged Report records list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.RequestReportRecordContract] + :param count: Total record count number across all pages. + :type count: long + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RequestReportRecordContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + } + + def __init__( + self, + *, + value: Optional[List["RequestReportRecordContract"]] = None, + count: Optional[int] = None, + **kwargs + ): + super(RequestReportCollection, self).__init__(**kwargs) + self.value = value + self.count = count + + +class RequestReportRecordContract(msrest.serialization.Model): """Request Report data. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :param api_id: API identifier path. /apis/{apiId} + :param api_id: API identifier path. /apis/{apiId}. :type api_id: str - :param operation_id: Operation identifier path. - /apis/{apiId}/operations/{operationId} + :param operation_id: Operation identifier path. /apis/{apiId}/operations/{operationId}. :type operation_id: str - :ivar product_id: Product identifier path. /products/{productId} + :ivar product_id: Product identifier path. /products/{productId}. :vartype product_id: str - :ivar user_id: User identifier path. /users/{userId} + :ivar user_id: User identifier path. /users/{userId}. :vartype user_id: str :param method: The HTTP method associated with this request.. :type method: str @@ -6555,32 +10312,29 @@ class RequestReportRecordContract(Model): :type url: str :param ip_address: The client IP address associated with this request. :type ip_address: str - :param backend_response_code: The HTTP status code received by the gateway - as a result of forwarding this request to the backend. + :param backend_response_code: The HTTP status code received by the gateway as a result of + forwarding this request to the backend. :type backend_response_code: str :param response_code: The HTTP status code returned by the gateway. :type response_code: int :param response_size: The size of the response returned by the gateway. :type response_size: int - :param timestamp: The date and time when this request was received by the - gateway in ISO 8601 format. - :type timestamp: datetime - :param cache: Specifies if response cache was involved in generating the - response. If the value is none, the cache was not used. If the value is - hit, cached response was returned. If the value is miss, the cache was - used but lookup resulted in a miss and request was fulfilled by the - backend. + :param timestamp: The date and time when this request was received by the gateway in ISO 8601 + format. + :type timestamp: ~datetime.datetime + :param cache: Specifies if response cache was involved in generating the response. If the value + is none, the cache was not used. If the value is hit, cached response was returned. If the + value is miss, the cache was used but lookup resulted in a miss and request was fulfilled by + the backend. :type cache: str :param api_time: The total time it took to process this request. :type api_time: float - :param service_time: he time it took to forward this request to the - backend and get the response back. + :param service_time: he time it took to forward this request to the backend and get the + response back. :type service_time: float - :param api_region: Azure region where the gateway that processed this - request is located. + :param api_region: Azure region where the gateway that processed this request is located. :type api_region: str - :param subscription_id: Subscription identifier path. - /subscriptions/{subscriptionId} + :param subscription_id: Subscription identifier path. /subscriptions/{subscriptionId}. :type subscription_id: str :param request_id: Request Identifier. :type request_id: str @@ -6614,7 +10368,27 @@ class RequestReportRecordContract(Model): 'request_size': {'key': 'requestSize', 'type': 'int'}, } - def __init__(self, *, api_id: str=None, operation_id: str=None, method: str=None, url: str=None, ip_address: str=None, backend_response_code: str=None, response_code: int=None, response_size: int=None, timestamp=None, cache: str=None, api_time: float=None, service_time: float=None, api_region: str=None, subscription_id: str=None, request_id: str=None, request_size: int=None, **kwargs) -> None: + def __init__( + self, + *, + api_id: Optional[str] = None, + operation_id: Optional[str] = None, + method: Optional[str] = None, + url: Optional[str] = None, + ip_address: Optional[str] = None, + backend_response_code: Optional[str] = None, + response_code: Optional[int] = None, + response_size: Optional[int] = None, + timestamp: Optional[datetime.datetime] = None, + cache: Optional[str] = None, + api_time: Optional[float] = None, + service_time: Optional[float] = None, + api_region: Optional[str] = None, + subscription_id: Optional[str] = None, + request_id: Optional[str] = None, + request_size: Optional[int] = None, + **kwargs + ): super(RequestReportRecordContract, self).__init__(**kwargs) self.api_id = api_id self.operation_id = operation_id @@ -6636,29 +10410,26 @@ def __init__(self, *, api_id: str=None, operation_id: str=None, method: str=None self.request_size = request_size -class ResourceLocationDataContract(Model): +class ResourceLocationDataContract(msrest.serialization.Model): """Resource location data properties. All required parameters must be populated in order to send to Azure. - :param name: Required. A canonical name for the geographic or physical - location. + :param name: Required. A canonical name for the geographic or physical location. :type name: str :param city: The city or locality where the resource is located. :type city: str - :param district: The district, state, or province where the resource is - located. + :param district: The district, state, or province where the resource is located. :type district: str - :param country_or_region: The country or region where the resource is - located. + :param country_or_region: The country or region where the resource is located. :type country_or_region: str """ _validation = { - 'name': {'required': True, 'max_length': 256}, - 'city': {'max_length': 256}, - 'district': {'max_length': 256}, - 'country_or_region': {'max_length': 256}, + 'name': {'required': True, 'max_length': 256, 'min_length': 0}, + 'city': {'max_length': 256, 'min_length': 0}, + 'district': {'max_length': 256, 'min_length': 0}, + 'country_or_region': {'max_length': 256, 'min_length': 0}, } _attribute_map = { @@ -6668,7 +10439,15 @@ class ResourceLocationDataContract(Model): 'country_or_region': {'key': 'countryOrRegion', 'type': 'str'}, } - def __init__(self, *, name: str, city: str=None, district: str=None, country_or_region: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: str, + city: Optional[str] = None, + district: Optional[str] = None, + country_or_region: Optional[str] = None, + **kwargs + ): super(ResourceLocationDataContract, self).__init__(**kwargs) self.name = name self.city = city @@ -6676,11 +10455,11 @@ def __init__(self, *, name: str, city: str=None, district: str=None, country_or_ self.country_or_region = country_or_region -class ResourceSku(Model): +class ResourceSku(msrest.serialization.Model): """Describes an available API Management SKU. - :param name: Name of the Sku. Possible values include: 'Developer', - 'Standard', 'Premium', 'Basic', 'Consumption' + :param name: Name of the Sku. Possible values include: "Developer", "Standard", "Premium", + "Basic", "Consumption", "Isolated". :type name: str or ~azure.mgmt.apimanagement.models.SkuType """ @@ -6688,16 +10467,20 @@ class ResourceSku(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, name=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[Union[str, "SkuType"]] = None, + **kwargs + ): super(ResourceSku, self).__init__(**kwargs) self.name = name -class ResourceSkuCapacity(Model): +class ResourceSkuCapacity(msrest.serialization.Model): """Describes scaling information of a SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar minimum: The minimum capacity. :vartype minimum: int @@ -6705,10 +10488,9 @@ class ResourceSkuCapacity(Model): :vartype maximum: int :ivar default: The default capacity. :vartype default: int - :ivar scale_type: The scale type applicable to the sku. Possible values - include: 'automatic', 'manual', 'none' - :vartype scale_type: str or - ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType + :ivar scale_type: The scale type applicable to the sku. Possible values include: "automatic", + "manual", "none". + :vartype scale_type: str or ~azure.mgmt.apimanagement.models.ResourceSkuCapacityScaleType """ _validation = { @@ -6725,7 +10507,10 @@ class ResourceSkuCapacity(Model): 'scale_type': {'key': 'scaleType', 'type': 'str'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceSkuCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -6733,11 +10518,10 @@ def __init__(self, **kwargs) -> None: self.scale_type = None -class ResourceSkuResult(Model): +class ResourceSkuResult(msrest.serialization.Model): """Describes an available API Management service SKU. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar resource_type: The type of resource the SKU applies to. :vartype resource_type: str @@ -6759,14 +10543,49 @@ class ResourceSkuResult(Model): 'capacity': {'key': 'capacity', 'type': 'ResourceSkuCapacity'}, } - def __init__(self, **kwargs) -> None: + def __init__( + self, + **kwargs + ): super(ResourceSkuResult, self).__init__(**kwargs) self.resource_type = None self.sku = None self.capacity = None -class ResponseContract(Model): +class ResourceSkuResults(msrest.serialization.Model): + """The API Management service SKUs operation response. + + All required parameters must be populated in order to send to Azure. + + :param value: Required. The list of skus available for the service. + :type value: list[~azure.mgmt.apimanagement.models.ResourceSkuResult] + :param next_link: The uri to fetch the next page of API Management service Skus. + :type next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceSkuResult]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["ResourceSkuResult"], + next_link: Optional[str] = None, + **kwargs + ): + super(ResourceSkuResults, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResponseContract(msrest.serialization.Model): """Operation response details. All required parameters must be populated in order to send to Azure. @@ -6776,8 +10595,7 @@ class ResponseContract(Model): :param description: Operation response description. :type description: str :param representations: Collection of operation response representations. - :type representations: - list[~azure.mgmt.apimanagement.models.RepresentationContract] + :type representations: list[~azure.mgmt.apimanagement.models.RepresentationContract] :param headers: Collection of operation response headers. :type headers: list[~azure.mgmt.apimanagement.models.ParameterContract] """ @@ -6793,7 +10611,15 @@ class ResponseContract(Model): 'headers': {'key': 'headers', 'type': '[ParameterContract]'}, } - def __init__(self, *, status_code: int, description: str=None, representations=None, headers=None, **kwargs) -> None: + def __init__( + self, + *, + status_code: int, + description: Optional[str] = None, + representations: Optional[List["RepresentationContract"]] = None, + headers: Optional[List["ParameterContract"]] = None, + **kwargs + ): super(ResponseContract, self).__init__(**kwargs) self.status_code = status_code self.description = description @@ -6801,10 +10627,10 @@ def __init__(self, *, status_code: int, description: str=None, representations=N self.headers = headers -class SamplingSettings(Model): +class SamplingSettings(msrest.serialization.Model): """Sampling settings for Diagnostic. - :param sampling_type: Sampling type. Possible values include: 'fixed' + :param sampling_type: Sampling type. Possible values include: "fixed". :type sampling_type: str or ~azure.mgmt.apimanagement.models.SamplingType :param percentage: Rate of sampling for fixed-rate sampling. :type percentage: float @@ -6819,48 +10645,80 @@ class SamplingSettings(Model): 'percentage': {'key': 'percentage', 'type': 'float'}, } - def __init__(self, *, sampling_type=None, percentage: float=None, **kwargs) -> None: + def __init__( + self, + *, + sampling_type: Optional[Union[str, "SamplingType"]] = None, + percentage: Optional[float] = None, + **kwargs + ): super(SamplingSettings, self).__init__(**kwargs) self.sampling_type = sampling_type self.percentage = percentage -class SaveConfigurationParameter(Model): +class SaveConfigurationParameter(msrest.serialization.Model): """Save Tenant Configuration Contract details. - All required parameters must be populated in order to send to Azure. - - :param branch: Required. The name of the Git branch in which to commit the - current configuration snapshot. + :param branch: The name of the Git branch in which to commit the current configuration + snapshot. :type branch: str - :param force: The value if true, the current configuration database is - committed to the Git repository, even if the Git repository has newer - changes that would be overwritten. + :param force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. :type force: bool """ - _validation = { - 'branch': {'required': True}, - } - _attribute_map = { 'branch': {'key': 'properties.branch', 'type': 'str'}, 'force': {'key': 'properties.force', 'type': 'bool'}, } - def __init__(self, *, branch: str, force: bool=None, **kwargs) -> None: + def __init__( + self, + *, + branch: Optional[str] = None, + force: Optional[bool] = None, + **kwargs + ): super(SaveConfigurationParameter, self).__init__(**kwargs) self.branch = branch self.force = force +class SchemaCollection(msrest.serialization.Model): + """The response of the list schema operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Api Schema Contract value. + :vartype value: list[~azure.mgmt.apimanagement.models.SchemaContract] + :ivar next_link: Next page link if any. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SchemaContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SchemaCollection, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class SchemaContract(Resource): """Schema Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6868,19 +10726,17 @@ class SchemaContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param content_type: Required. Must be a valid a media type used in a - Content-Type header as defined in the RFC 2616. Media type of the schema - document (e.g. application/json, application/xml).
- `Swagger` - Schema use `application/vnd.ms-azure-apim.swagger.definitions+json`
- - `WSDL` Schema use `application/vnd.ms-azure-apim.xsd+xml`
- - `OpenApi` Schema use `application/vnd.oai.openapi.components+json`
- - `WADL Schema` use `application/vnd.ms-azure-apim.wadl.grammars+xml`. + :param content_type: Must be a valid a media type used in a Content-Type header as defined in + the RFC 2616. Media type of the schema document (e.g. application/json, application/xml).
+ - ``Swagger`` Schema use ``application/vnd.ms-azure-apim.swagger.definitions+json``
- + ``WSDL`` Schema use ``application/vnd.ms-azure-apim.xsd+xml``
- ``OpenApi`` Schema use + ``application/vnd.oai.openapi.components+json``
- ``WADL Schema`` use + ``application/vnd.ms-azure-apim.wadl.grammars+xml``. :type content_type: str - :param value: Json escaped string defining the document representing the - Schema. Used for schemas other than Swagger/OpenAPI. + :param value: Json escaped string defining the document representing the Schema. Used for + schemas other than Swagger/OpenAPI. :type value: str - :param definitions: Types definitions. Used for Swagger/OpenAPI schemas - only, null otherwise. + :param definitions: Types definitions. Used for Swagger/OpenAPI schemas only, null otherwise. :type definitions: object """ @@ -6888,7 +10744,6 @@ class SchemaContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'content_type': {'required': True}, } _attribute_map = { @@ -6900,20 +10755,50 @@ class SchemaContract(Resource): 'definitions': {'key': 'properties.document.definitions', 'type': 'object'}, } - def __init__(self, *, content_type: str, value: str=None, definitions=None, **kwargs) -> None: + def __init__( + self, + *, + content_type: Optional[str] = None, + value: Optional[str] = None, + definitions: Optional[object] = None, + **kwargs + ): super(SchemaContract, self).__init__(**kwargs) self.content_type = content_type self.value = value self.definitions = definitions +class SubscriptionCollection(msrest.serialization.Model): + """Paged Subscriptions list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.SubscriptionContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SubscriptionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["SubscriptionContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(SubscriptionCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class SubscriptionContract(Resource): """Subscription details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -6921,64 +10806,53 @@ class SubscriptionContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param owner_id: The user resource identifier of the subscription owner. - The value is a valid relative URL in the format of /users/{userId} where - {userId} is a user identifier. + :param owner_id: The user resource identifier of the subscription owner. The value is a valid + relative URL in the format of /users/{userId} where {userId} is a user identifier. :type owner_id: str - :param scope: Required. Scope like /products/{productId} or /apis or - /apis/{apiId}. + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param display_name: The name of the subscription, or null if the - subscription has no name. + :param display_name: The name of the subscription, or null if the subscription has no name. :type display_name: str - :param state: Required. Subscription state. Possible states are * active – - the subscription is active, * suspended – the subscription is blocked, and - the subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :ivar created_date: Subscription creation date. The date conforms to the - following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :vartype created_date: datetime - :param start_date: Subscription activation date. The setting is for audit - purposes only and the subscription is not automatically activated. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type start_date: datetime - :param expiration_date: Subscription expiration date. The setting is for - audit purposes only and the subscription is not automatically expired. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime - :param end_date: Date when subscription was cancelled or expired. The - setting is for audit purposes only and the subscription is not - automatically cancelled. The subscription lifecycle can be managed by - using the `state` property. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type end_date: datetime - :param notification_date: Upcoming subscription expiration notification - date. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as + :ivar created_date: Subscription creation date. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :vartype created_date: ~datetime.datetime + :param start_date: Subscription activation date. The setting is for audit purposes only and the + subscription is not automatically activated. The subscription lifecycle can be managed by using + the ``state`` property. The date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. - :type notification_date: datetime - :param primary_key: Subscription primary key. This property will not be - filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :type start_date: ~datetime.datetime + :param expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: ``yyyy-MM- + ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime + :param end_date: Date when subscription was cancelled or expired. The setting is for audit + purposes only and the subscription is not automatically cancelled. The subscription lifecycle + can be managed by using the ``state`` property. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type end_date: ~datetime.datetime + :param notification_date: Upcoming subscription expiration notification date. The date conforms + to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type notification_date: ~datetime.datetime + :param primary_key: Subscription primary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type primary_key: str - :param secondary_key: Subscription secondary key. This property will not - be filled on 'GET' operations! Use '/listSecrets' POST request to get the - value. + :param secondary_key: Subscription secondary key. This property will not be filled on 'GET' + operations! Use '/listSecrets' POST request to get the value. :type secondary_key: str - :param state_comment: Optional subscription comment added by an - administrator. + :param state_comment: Optional subscription comment added by an administrator when the state is + changed to the 'rejected'. :type state_comment: str - :param allow_tracing: Determines whether tracing is enabled + :param allow_tracing: Determines whether tracing is enabled. :type allow_tracing: bool """ @@ -6986,9 +10860,7 @@ class SubscriptionContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'scope': {'required': True}, 'display_name': {'max_length': 100, 'min_length': 0}, - 'state': {'required': True}, 'created_date': {'readonly': True}, 'primary_key': {'max_length': 256, 'min_length': 1}, 'secondary_key': {'max_length': 256, 'min_length': 1}, @@ -7001,7 +10873,7 @@ class SubscriptionContract(Resource): 'owner_id': {'key': 'properties.ownerId', 'type': 'str'}, 'scope': {'key': 'properties.scope', 'type': 'str'}, 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'created_date': {'key': 'properties.createdDate', 'type': 'iso-8601'}, 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, @@ -7013,7 +10885,23 @@ class SubscriptionContract(Resource): 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, *, scope: str, state, owner_id: str=None, display_name: str=None, start_date=None, expiration_date=None, end_date=None, notification_date=None, primary_key: str=None, secondary_key: str=None, state_comment: str=None, allow_tracing: bool=None, **kwargs) -> None: + def __init__( + self, + *, + owner_id: Optional[str] = None, + scope: Optional[str] = None, + display_name: Optional[str] = None, + state: Optional[Union[str, "SubscriptionState"]] = None, + start_date: Optional[datetime.datetime] = None, + expiration_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + notification_date: Optional[datetime.datetime] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state_comment: Optional[str] = None, + allow_tracing: Optional[bool] = None, + **kwargs + ): super(SubscriptionContract, self).__init__(**kwargs) self.owner_id = owner_id self.scope = scope @@ -7030,43 +10918,38 @@ def __init__(self, *, scope: str, state, owner_id: str=None, display_name: str=N self.allow_tracing = allow_tracing -class SubscriptionCreateParameters(Model): +class SubscriptionCreateParameters(msrest.serialization.Model): """Subscription create details. - All required parameters must be populated in order to send to Azure. - - :param owner_id: User (user id path) for whom subscription is being - created in form /users/{userId} + :param owner_id: User (user id path) for whom subscription is being created in form + /users/{userId}. :type owner_id: str - :param scope: Required. Scope like /products/{productId} or /apis or - /apis/{apiId}. + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param display_name: Required. Subscription name. + :param display_name: Subscription name. :type display_name: str - :param primary_key: Primary subscription key. If not specified during - request key will be generated automatically. + :param primary_key: Primary subscription key. If not specified during request key will be + generated automatically. :type primary_key: str - :param secondary_key: Secondary subscription key. If not specified during - request key will be generated automatically. + :param secondary_key: Secondary subscription key. If not specified during request key will be + generated automatically. :type secondary_key: str - :param state: Initial subscription state. If no value is specified, - subscription is created with Submitted state. Possible states are * active - – the subscription is active, * suspended – the subscription is blocked, - and the subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Initial subscription state. If no value is specified, subscription is created + with Submitted state. Possible states are * active – the subscription is active, * suspended – + the subscription is blocked, and the subscriber cannot call any APIs of the product, * + submitted – the subscription request has been made by the developer, but has not yet been + approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param allow_tracing: Determines whether tracing can be enabled + :param allow_tracing: Determines whether tracing can be enabled. :type allow_tracing: bool """ _validation = { - 'scope': {'required': True}, - 'display_name': {'required': True, 'max_length': 100, 'min_length': 1}, + 'display_name': {'max_length': 100, 'min_length': 1}, 'primary_key': {'max_length': 256, 'min_length': 1}, 'secondary_key': {'max_length': 256, 'min_length': 1}, } @@ -7077,11 +10960,22 @@ class SubscriptionCreateParameters(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, *, scope: str, display_name: str, owner_id: str=None, primary_key: str=None, secondary_key: str=None, state=None, allow_tracing: bool=None, **kwargs) -> None: + def __init__( + self, + *, + owner_id: Optional[str] = None, + scope: Optional[str] = None, + display_name: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state: Optional[Union[str, "SubscriptionState"]] = None, + allow_tracing: Optional[bool] = None, + **kwargs + ): super(SubscriptionCreateParameters, self).__init__(**kwargs) self.owner_id = owner_id self.scope = scope @@ -7092,7 +10986,7 @@ def __init__(self, *, scope: str, display_name: str, owner_id: str=None, primary self.allow_tracing = allow_tracing -class SubscriptionKeyParameterNamesContract(Model): +class SubscriptionKeyParameterNamesContract(msrest.serialization.Model): """Subscription key parameter names details. :param header: Subscription key header name. @@ -7106,13 +11000,19 @@ class SubscriptionKeyParameterNamesContract(Model): 'query': {'key': 'query', 'type': 'str'}, } - def __init__(self, *, header: str=None, query: str=None, **kwargs) -> None: + def __init__( + self, + *, + header: Optional[str] = None, + query: Optional[str] = None, + **kwargs + ): super(SubscriptionKeyParameterNamesContract, self).__init__(**kwargs) self.header = header self.query = query -class SubscriptionKeysContract(Model): +class SubscriptionKeysContract(msrest.serialization.Model): """Subscription keys. :param primary_key: Subscription primary key. @@ -7131,13 +11031,19 @@ class SubscriptionKeysContract(Model): 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, } - def __init__(self, *, primary_key: str=None, secondary_key: str=None, **kwargs) -> None: + def __init__( + self, + *, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs + ): super(SubscriptionKeysContract, self).__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key -class SubscriptionsDelegationSettingsProperties(Model): +class SubscriptionsDelegationSettingsProperties(msrest.serialization.Model): """Subscriptions delegation settings properties. :param enabled: Enable or disable delegation for subscriptions. @@ -7148,44 +11054,47 @@ class SubscriptionsDelegationSettingsProperties(Model): 'enabled': {'key': 'enabled', 'type': 'bool'}, } - def __init__(self, *, enabled: bool=None, **kwargs) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): super(SubscriptionsDelegationSettingsProperties, self).__init__(**kwargs) self.enabled = enabled -class SubscriptionUpdateParameters(Model): +class SubscriptionUpdateParameters(msrest.serialization.Model): """Subscription update details. - :param owner_id: User identifier path: /users/{userId} + :param owner_id: User identifier path: /users/{userId}. :type owner_id: str - :param scope: Scope like /products/{productId} or /apis or /apis/{apiId} + :param scope: Scope like /products/{productId} or /apis or /apis/{apiId}. :type scope: str - :param expiration_date: Subscription expiration date. The setting is for - audit purposes only and the subscription is not automatically expired. The - subscription lifecycle can be managed by using the `state` property. The - date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified - by the ISO 8601 standard. - :type expiration_date: datetime + :param expiration_date: Subscription expiration date. The setting is for audit purposes only + and the subscription is not automatically expired. The subscription lifecycle can be managed by + using the ``state`` property. The date conforms to the following format: ``yyyy-MM- + ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type expiration_date: ~datetime.datetime :param display_name: Subscription name. :type display_name: str :param primary_key: Primary subscription key. :type primary_key: str :param secondary_key: Secondary subscription key. :type secondary_key: str - :param state: Subscription state. Possible states are * active – the - subscription is active, * suspended – the subscription is blocked, and the - subscriber cannot call any APIs of the product, * submitted – the - subscription request has been made by the developer, but has not yet been - approved or rejected, * rejected – the subscription request has been - denied by an administrator, * cancelled – the subscription has been - cancelled by the developer or administrator, * expired – the subscription - reached its expiration date and was deactivated. Possible values include: - 'suspended', 'active', 'expired', 'submitted', 'rejected', 'cancelled' + :param state: Subscription state. Possible states are * active – the subscription is active, * + suspended – the subscription is blocked, and the subscriber cannot call any APIs of the + product, * submitted – the subscription request has been made by the developer, but has not yet + been approved or rejected, * rejected – the subscription request has been denied by an + administrator, * cancelled – the subscription has been cancelled by the developer or + administrator, * expired – the subscription reached its expiration date and was deactivated. + Possible values include: "suspended", "active", "expired", "submitted", "rejected", + "cancelled". :type state: str or ~azure.mgmt.apimanagement.models.SubscriptionState - :param state_comment: Comments describing subscription state change by the - administrator. + :param state_comment: Comments describing subscription state change by the administrator when + the state is changed to the 'rejected'. :type state_comment: str - :param allow_tracing: Determines whether tracing can be enabled + :param allow_tracing: Determines whether tracing can be enabled. :type allow_tracing: bool """ @@ -7201,12 +11110,25 @@ class SubscriptionUpdateParameters(Model): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, 'primary_key': {'key': 'properties.primaryKey', 'type': 'str'}, 'secondary_key': {'key': 'properties.secondaryKey', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'SubscriptionState'}, + 'state': {'key': 'properties.state', 'type': 'str'}, 'state_comment': {'key': 'properties.stateComment', 'type': 'str'}, 'allow_tracing': {'key': 'properties.allowTracing', 'type': 'bool'}, } - def __init__(self, *, owner_id: str=None, scope: str=None, expiration_date=None, display_name: str=None, primary_key: str=None, secondary_key: str=None, state=None, state_comment: str=None, allow_tracing: bool=None, **kwargs) -> None: + def __init__( + self, + *, + owner_id: Optional[str] = None, + scope: Optional[str] = None, + expiration_date: Optional[datetime.datetime] = None, + display_name: Optional[str] = None, + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + state: Optional[Union[str, "SubscriptionState"]] = None, + state_comment: Optional[str] = None, + allow_tracing: Optional[bool] = None, + **kwargs + ): super(SubscriptionUpdateParameters, self).__init__(**kwargs) self.owner_id = owner_id self.scope = scope @@ -7219,13 +11141,36 @@ def __init__(self, *, owner_id: str=None, scope: str=None, expiration_date=None, self.allow_tracing = allow_tracing +class TagCollection(msrest.serialization.Model): + """Paged Tag list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(TagCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class TagContract(Resource): """Tag Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. - - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7233,7 +11178,7 @@ class TagContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param display_name: Required. Tag name. + :param display_name: Tag name. :type display_name: str """ @@ -7241,7 +11186,7 @@ class TagContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'display_name': {'required': True, 'max_length': 160, 'min_length': 1}, + 'display_name': {'max_length': 160, 'min_length': 1}, } _attribute_map = { @@ -7251,38 +11196,106 @@ class TagContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, *, display_name: str, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + **kwargs + ): super(TagContract, self).__init__(**kwargs) self.display_name = display_name -class TagCreateUpdateParameters(Model): +class TagCreateUpdateParameters(msrest.serialization.Model): """Parameters supplied to Create/Update Tag operations. - All required parameters must be populated in order to send to Azure. - - :param display_name: Required. Tag name. + :param display_name: Tag name. :type display_name: str """ _validation = { - 'display_name': {'required': True, 'max_length': 160, 'min_length': 1}, + 'display_name': {'max_length': 160, 'min_length': 1}, } _attribute_map = { 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, *, display_name: str, **kwargs) -> None: + def __init__( + self, + *, + display_name: Optional[str] = None, + **kwargs + ): super(TagCreateUpdateParameters, self).__init__(**kwargs) self.display_name = display_name +class TagDescriptionBaseProperties(msrest.serialization.Model): + """Parameters supplied to the Create TagDescription operation. + + :param description: Description of the Tag. + :type description: str + :param external_docs_url: Absolute URL of external resources describing the tag. + :type external_docs_url: str + :param external_docs_description: Description of the external resources describing the tag. + :type external_docs_description: str + """ + + _validation = { + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, + 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + **kwargs + ): + super(TagDescriptionBaseProperties, self).__init__(**kwargs) + self.description = description + self.external_docs_url = external_docs_url + self.external_docs_description = external_docs_description + + +class TagDescriptionCollection(msrest.serialization.Model): + """Paged TagDescription list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagDescriptionContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagDescriptionContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagDescriptionContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(TagDescriptionCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class TagDescriptionContract(Resource): """Contract details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7292,13 +11305,11 @@ class TagDescriptionContract(Resource): :vartype type: str :param description: Description of the Tag. :type description: str - :param external_docs_url: Absolute URL of external resources describing - the tag. + :param external_docs_url: Absolute URL of external resources describing the tag. :type external_docs_url: str - :param external_docs_description: Description of the external resources - describing the tag. + :param external_docs_description: Description of the external resources describing the tag. :type external_docs_description: str - :param tag_id: Identifier of the tag in the form of /tags/{tagId} + :param tag_id: Identifier of the tag in the form of /tags/{tagId}. :type tag_id: str :param display_name: Tag name. :type display_name: str @@ -7308,7 +11319,7 @@ class TagDescriptionContract(Resource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, - 'external_docs_url': {'max_length': 2000}, + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, 'display_name': {'max_length': 160, 'min_length': 1}, } @@ -7323,7 +11334,16 @@ class TagDescriptionContract(Resource): 'display_name': {'key': 'properties.displayName', 'type': 'str'}, } - def __init__(self, *, description: str=None, external_docs_url: str=None, external_docs_description: str=None, tag_id: str=None, display_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + tag_id: Optional[str] = None, + display_name: Optional[str] = None, + **kwargs + ): super(TagDescriptionContract, self).__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url @@ -7332,21 +11352,62 @@ def __init__(self, *, description: str=None, external_docs_url: str=None, extern self.display_name = display_name -class TagDescriptionCreateParameters(Model): +class TagDescriptionContractProperties(TagDescriptionBaseProperties): + """TagDescription contract Properties. + + :param description: Description of the Tag. + :type description: str + :param external_docs_url: Absolute URL of external resources describing the tag. + :type external_docs_url: str + :param external_docs_description: Description of the external resources describing the tag. + :type external_docs_description: str + :param tag_id: Identifier of the tag in the form of /tags/{tagId}. + :type tag_id: str + :param display_name: Tag name. + :type display_name: str + """ + + _validation = { + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, + 'display_name': {'max_length': 160, 'min_length': 1}, + } + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'external_docs_url': {'key': 'externalDocsUrl', 'type': 'str'}, + 'external_docs_description': {'key': 'externalDocsDescription', 'type': 'str'}, + 'tag_id': {'key': 'tagId', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + tag_id: Optional[str] = None, + display_name: Optional[str] = None, + **kwargs + ): + super(TagDescriptionContractProperties, self).__init__(description=description, external_docs_url=external_docs_url, external_docs_description=external_docs_description, **kwargs) + self.tag_id = tag_id + self.display_name = display_name + + +class TagDescriptionCreateParameters(msrest.serialization.Model): """Parameters supplied to the Create TagDescription operation. :param description: Description of the Tag. :type description: str - :param external_docs_url: Absolute URL of external resources describing - the tag. + :param external_docs_url: Absolute URL of external resources describing the tag. :type external_docs_url: str - :param external_docs_description: Description of the external resources - describing the tag. + :param external_docs_description: Description of the external resources describing the tag. :type external_docs_description: str """ _validation = { - 'external_docs_url': {'max_length': 2000}, + 'external_docs_url': {'max_length': 2000, 'min_length': 0}, } _attribute_map = { @@ -7355,30 +11416,59 @@ class TagDescriptionCreateParameters(Model): 'external_docs_description': {'key': 'properties.externalDocsDescription', 'type': 'str'}, } - def __init__(self, *, description: str=None, external_docs_url: str=None, external_docs_description: str=None, **kwargs) -> None: + def __init__( + self, + *, + description: Optional[str] = None, + external_docs_url: Optional[str] = None, + external_docs_description: Optional[str] = None, + **kwargs + ): super(TagDescriptionCreateParameters, self).__init__(**kwargs) self.description = description self.external_docs_url = external_docs_url self.external_docs_description = external_docs_description -class TagResourceContract(Model): +class TagResourceCollection(msrest.serialization.Model): + """Paged Tag list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.TagResourceContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TagResourceContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TagResourceContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(TagResourceCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class TagResourceContract(msrest.serialization.Model): """TagResource contract properties. All required parameters must be populated in order to send to Azure. :param tag: Required. Tag associated with the resource. - :type tag: - ~azure.mgmt.apimanagement.models.TagTagResourceContractProperties + :type tag: ~azure.mgmt.apimanagement.models.TagResourceContractProperties :param api: Api associated with the tag. - :type api: - ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties + :type api: ~azure.mgmt.apimanagement.models.ApiTagResourceContractProperties :param operation: Operation associated with the tag. - :type operation: - ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties + :type operation: ~azure.mgmt.apimanagement.models.OperationTagResourceContractProperties :param product: Product associated with the tag. - :type product: - ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties + :type product: ~azure.mgmt.apimanagement.models.ProductTagResourceContractProperties """ _validation = { @@ -7386,13 +11476,21 @@ class TagResourceContract(Model): } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'TagTagResourceContractProperties'}, + 'tag': {'key': 'tag', 'type': 'TagResourceContractProperties'}, 'api': {'key': 'api', 'type': 'ApiTagResourceContractProperties'}, 'operation': {'key': 'operation', 'type': 'OperationTagResourceContractProperties'}, 'product': {'key': 'product', 'type': 'ProductTagResourceContractProperties'}, } - def __init__(self, *, tag, api=None, operation=None, product=None, **kwargs) -> None: + def __init__( + self, + *, + tag: "TagResourceContractProperties", + api: Optional["ApiTagResourceContractProperties"] = None, + operation: Optional["OperationTagResourceContractProperties"] = None, + product: Optional["ProductTagResourceContractProperties"] = None, + **kwargs + ): super(TagResourceContract, self).__init__(**kwargs) self.tag = tag self.api = api @@ -7400,12 +11498,12 @@ def __init__(self, *, tag, api=None, operation=None, product=None, **kwargs) -> self.product = product -class TagTagResourceContractProperties(Model): +class TagResourceContractProperties(msrest.serialization.Model): """Contract defining the Tag property in the Tag Resource Contract. - :param id: Tag identifier + :param id: Tag identifier. :type id: str - :param name: Tag Name + :param name: Tag Name. :type name: str """ @@ -7418,36 +11516,39 @@ class TagTagResourceContractProperties(Model): 'name': {'key': 'name', 'type': 'str'}, } - def __init__(self, *, id: str=None, name: str=None, **kwargs) -> None: - super(TagTagResourceContractProperties, self).__init__(**kwargs) + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + **kwargs + ): + super(TagResourceContractProperties, self).__init__(**kwargs) self.id = id self.name = name -class TenantConfigurationSyncStateContract(Model): +class TenantConfigurationSyncStateContract(msrest.serialization.Model): """Tenant Configuration Synchronization State. :param branch: The name of Git branch. :type branch: str :param commit_id: The latest commit Id. :type commit_id: str - :param is_export: value indicating if last sync was save (true) or deploy - (false) operation. + :param is_export: value indicating if last sync was save (true) or deploy (false) operation. :type is_export: bool - :param is_synced: value indicating if last synchronization was later than - the configuration change. + :param is_synced: value indicating if last synchronization was later than the configuration + change. :type is_synced: bool - :param is_git_enabled: value indicating whether Git configuration access - is enabled. + :param is_git_enabled: value indicating whether Git configuration access is enabled. :type is_git_enabled: bool - :param sync_date: The date of the latest synchronization. The date - conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by - the ISO 8601 standard. - :type sync_date: datetime - :param configuration_change_date: The date of the latest configuration - change. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` - as specified by the ISO 8601 standard. - :type configuration_change_date: datetime + :param sync_date: The date of the latest synchronization. The date conforms to the following + format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type sync_date: ~datetime.datetime + :param configuration_change_date: The date of the latest configuration change. The date + conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type configuration_change_date: ~datetime.datetime """ _attribute_map = { @@ -7460,7 +11561,18 @@ class TenantConfigurationSyncStateContract(Model): 'configuration_change_date': {'key': 'configurationChangeDate', 'type': 'iso-8601'}, } - def __init__(self, *, branch: str=None, commit_id: str=None, is_export: bool=None, is_synced: bool=None, is_git_enabled: bool=None, sync_date=None, configuration_change_date=None, **kwargs) -> None: + def __init__( + self, + *, + branch: Optional[str] = None, + commit_id: Optional[str] = None, + is_export: Optional[bool] = None, + is_synced: Optional[bool] = None, + is_git_enabled: Optional[bool] = None, + sync_date: Optional[datetime.datetime] = None, + configuration_change_date: Optional[datetime.datetime] = None, + **kwargs + ): super(TenantConfigurationSyncStateContract, self).__init__(**kwargs) self.branch = branch self.commit_id = commit_id @@ -7471,7 +11583,7 @@ def __init__(self, *, branch: str=None, commit_id: str=None, is_export: bool=Non self.configuration_change_date = configuration_change_date -class TermsOfServiceProperties(Model): +class TermsOfServiceProperties(msrest.serialization.Model): """Terms of service contract properties. :param text: A terms of service text. @@ -7488,14 +11600,21 @@ class TermsOfServiceProperties(Model): 'consent_required': {'key': 'consentRequired', 'type': 'bool'}, } - def __init__(self, *, text: str=None, enabled: bool=None, consent_required: bool=None, **kwargs) -> None: + def __init__( + self, + *, + text: Optional[str] = None, + enabled: Optional[bool] = None, + consent_required: Optional[bool] = None, + **kwargs + ): super(TermsOfServiceProperties, self).__init__(**kwargs) self.text = text self.enabled = enabled self.consent_required = consent_required -class TokenBodyParameterContract(Model): +class TokenBodyParameterContract(msrest.serialization.Model): """OAuth acquire token request body parameter (www-url-form-encoded). All required parameters must be populated in order to send to Azure. @@ -7516,17 +11635,48 @@ class TokenBodyParameterContract(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, name: str, value: str, **kwargs) -> None: + def __init__( + self, + *, + name: str, + value: str, + **kwargs + ): super(TokenBodyParameterContract, self).__init__(**kwargs) self.name = name self.value = value +class UserCollection(msrest.serialization.Model): + """Paged Users list representation. + + :param value: Page values. + :type value: list[~azure.mgmt.apimanagement.models.UserContract] + :param next_link: Next page link if any. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UserContract]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["UserContract"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(UserCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + class UserContract(Resource): """User details. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Resource ID. :vartype id: str @@ -7534,30 +11684,26 @@ class UserContract(Resource): :vartype name: str :ivar type: Resource type for API Management resource. :vartype type: str - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] :param first_name: First name. :type first_name: str :param last_name: Last name. :type last_name: str :param email: Email address. :type email: str - :param registration_date: Date of user registration. The date conforms to - the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 - standard. - :type registration_date: datetime + :param registration_date: Date of user registration. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type registration_date: ~datetime.datetime :ivar groups: Collection of groups user is part of. - :vartype groups: - list[~azure.mgmt.apimanagement.models.GroupContractProperties] + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] """ _validation = { @@ -7581,7 +11727,18 @@ class UserContract(Resource): 'groups': {'key': 'properties.groups', 'type': '[GroupContractProperties]'}, } - def __init__(self, *, state="active", note: str=None, identities=None, first_name: str=None, last_name: str=None, email: str=None, registration_date=None, **kwargs) -> None: + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + registration_date: Optional[datetime.datetime] = None, + **kwargs + ): super(UserContract, self).__init__(**kwargs) self.state = state self.note = note @@ -7593,39 +11750,130 @@ def __init__(self, *, state="active", note: str=None, identities=None, first_nam self.groups = None -class UserCreateParameters(Model): - """User create details. +class UserEntityBaseParameters(msrest.serialization.Model): + """User Entity Base Parameters set. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + """ + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + **kwargs + ): + super(UserEntityBaseParameters, self).__init__(**kwargs) + self.state = state + self.note = note + self.identities = identities + + +class UserContractProperties(UserEntityBaseParameters): + """User profile. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param email: Email address. + :type email: str + :param registration_date: Date of user registration. The date conforms to the following format: + ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 standard. + :type registration_date: ~datetime.datetime + :ivar groups: Collection of groups user is part of. + :vartype groups: list[~azure.mgmt.apimanagement.models.GroupContractProperties] + """ + + _validation = { + 'groups': {'readonly': True}, + } + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'registration_date': {'key': 'registrationDate', 'type': 'iso-8601'}, + 'groups': {'key': 'groups', 'type': '[GroupContractProperties]'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + email: Optional[str] = None, + registration_date: Optional[datetime.datetime] = None, + **kwargs + ): + super(UserContractProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + self.first_name = first_name + self.last_name = last_name + self.email = email + self.registration_date = registration_date + self.groups = None + + +class UserCreateParameterProperties(UserEntityBaseParameters): + """Parameters supplied to the Create User operation. All required parameters must be populated in order to send to Azure. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Required. Email address. Must not be empty and must be - unique within the service instance. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Required. Email address. Must not be empty and must be unique within the service + instance. :type email: str :param first_name: Required. First name. :type first_name: str :param last_name: Required. Last name. :type last_name: str - :param password: User Password. If no value is provided, a default - password is generated. + :param password: User Password. If no value is provided, a default password is generated. :type password: str - :param app_type: Determines the type of application which send the create - user request. Default is old publisher portal. Possible values include: - 'developerPortal' + :param app_type: Determines the type of application which send the create user request. Default + is legacy portal. Possible values include: "portal", "developerPortal". :type app_type: str or ~azure.mgmt.apimanagement.models.AppType - :param confirmation: Determines the type of confirmation e-mail that will - be sent to the newly created user. Possible values include: 'signup', - 'invite' + :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + created user. Possible values include: "signup", "invite". :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation """ @@ -7635,6 +11883,75 @@ class UserCreateParameters(Model): 'last_name': {'required': True, 'max_length': 100, 'min_length': 1}, } + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'email': {'key': 'email', 'type': 'str'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + 'app_type': {'key': 'appType', 'type': 'str'}, + 'confirmation': {'key': 'confirmation', 'type': 'str'}, + } + + def __init__( + self, + *, + email: str, + first_name: str, + last_name: str, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + password: Optional[str] = None, + app_type: Optional[Union[str, "AppType"]] = None, + confirmation: Optional[Union[str, "Confirmation"]] = None, + **kwargs + ): + super(UserCreateParameterProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + self.email = email + self.first_name = first_name + self.last_name = last_name + self.password = password + self.app_type = app_type + self.confirmation = confirmation + + +class UserCreateParameters(msrest.serialization.Model): + """User create details. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. + :type email: str + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + :param password: User Password. If no value is provided, a default password is generated. + :type password: str + :param app_type: Determines the type of application which send the create user request. Default + is legacy portal. Possible values include: "portal", "developerPortal". + :type app_type: str or ~azure.mgmt.apimanagement.models.AppType + :param confirmation: Determines the type of confirmation e-mail that will be sent to the newly + created user. Possible values include: "signup", "invite". + :type confirmation: str or ~azure.mgmt.apimanagement.models.Confirmation + """ + + _validation = { + 'email': {'max_length': 254, 'min_length': 1}, + 'first_name': {'max_length': 100, 'min_length': 1}, + 'last_name': {'max_length': 100, 'min_length': 1}, + } + _attribute_map = { 'state': {'key': 'properties.state', 'type': 'str'}, 'note': {'key': 'properties.note', 'type': 'str'}, @@ -7647,7 +11964,20 @@ class UserCreateParameters(Model): 'confirmation': {'key': 'properties.confirmation', 'type': 'str'}, } - def __init__(self, *, email: str, first_name: str, last_name: str, state="active", note: str=None, identities=None, password: str=None, app_type=None, confirmation=None, **kwargs) -> None: + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["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, + **kwargs + ): super(UserCreateParameters, self).__init__(**kwargs) self.state = state self.note = note @@ -7660,36 +11990,38 @@ def __init__(self, *, email: str, first_name: str, last_name: str, state="active self.confirmation = confirmation -class UserEntityBaseParameters(Model): - """User Entity Base Parameters set. +class UserIdentityCollection(msrest.serialization.Model): + """List of Users Identity list representation. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . - :type state: str or ~azure.mgmt.apimanagement.models.UserState - :param note: Optional note about a user set by the administrator. - :type note: str - :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param value: User Identity values. + :type value: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param count: Total record count number across all pages. + :type count: long + :param next_link: Next page link if any. + :type next_link: str """ _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'note': {'key': 'note', 'type': 'str'}, - 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'value': {'key': 'value', 'type': '[UserIdentityContract]'}, + 'count': {'key': 'count', 'type': 'long'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, } - def __init__(self, *, state="active", note: str=None, identities=None, **kwargs) -> None: - super(UserEntityBaseParameters, self).__init__(**kwargs) - self.state = state - self.note = note - self.identities = identities + def __init__( + self, + *, + value: Optional[List["UserIdentityContract"]] = None, + count: Optional[int] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(UserIdentityCollection, self).__init__(**kwargs) + self.value = value + self.count = count + self.next_link = next_link -class UserIdentityContract(Model): +class UserIdentityContract(msrest.serialization.Model): """User identity details. :param provider: Identity provider name. @@ -7703,13 +12035,19 @@ class UserIdentityContract(Model): 'id': {'key': 'id', 'type': 'str'}, } - def __init__(self, *, provider: str=None, id: str=None, **kwargs) -> None: + def __init__( + self, + *, + provider: Optional[str] = None, + id: Optional[str] = None, + **kwargs + ): super(UserIdentityContract, self).__init__(**kwargs) self.provider = provider self.id = id -class UserIdentityProperties(Model): +class UserIdentityProperties(msrest.serialization.Model): """UserIdentityProperties. :param principal_id: The principal id of user assigned identity. @@ -7723,44 +12061,48 @@ class UserIdentityProperties(Model): 'client_id': {'key': 'clientId', 'type': 'str'}, } - def __init__(self, *, principal_id: str=None, client_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + **kwargs + ): super(UserIdentityProperties, self).__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id -class UserTokenParameters(Model): +class UserTokenParameters(msrest.serialization.Model): """Get User Token parameters. - All required parameters must be populated in order to send to Azure. - - :param key_type: Required. The Key to be used to generate token for user. - Possible values include: 'primary', 'secondary'. Default value: "primary" - . + :param key_type: The Key to be used to generate token for user. Possible values include: + "primary", "secondary". :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: Required. The Expiry time of the Token. Maximum token - expiry time is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime """ - _validation = { - 'key_type': {'required': True}, - 'expiry': {'required': True}, - } - _attribute_map = { - 'key_type': {'key': 'properties.keyType', 'type': 'KeyType'}, + 'key_type': {'key': 'properties.keyType', 'type': 'str'}, 'expiry': {'key': 'properties.expiry', 'type': 'iso-8601'}, } - def __init__(self, *, expiry, key_type="primary", **kwargs) -> None: + def __init__( + self, + *, + key_type: Optional[Union[str, "KeyType"]] = None, + expiry: Optional[datetime.datetime] = None, + **kwargs + ): super(UserTokenParameters, self).__init__(**kwargs) self.key_type = key_type self.expiry = expiry -class UserTokenResult(Model): +class UserTokenResult(msrest.serialization.Model): """Get User Token response details. :param value: Shared Access Authorization token for the User. @@ -7771,27 +12113,29 @@ class UserTokenResult(Model): 'value': {'key': 'value', 'type': 'str'}, } - def __init__(self, *, value: str=None, **kwargs) -> None: + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): super(UserTokenResult, self).__init__(**kwargs) self.value = value -class UserUpdateParameters(Model): +class UserUpdateParameters(msrest.serialization.Model): """User update parameters. - :param state: Account state. Specifies whether the user is active or not. - Blocked users are unable to sign into the developer portal or call any - APIs of subscribed products. Default state is Active. Possible values - include: 'active', 'blocked', 'pending', 'deleted'. Default value: - "active" . + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". :type state: str or ~azure.mgmt.apimanagement.models.UserState :param note: Optional note about a user set by the administrator. :type note: str :param identities: Collection of user identities. - :type identities: - list[~azure.mgmt.apimanagement.models.UserIdentityContract] - :param email: Email address. Must not be empty and must be unique within - the service instance. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. :type email: str :param password: User Password. :type password: str @@ -7817,7 +12161,18 @@ class UserUpdateParameters(Model): 'last_name': {'key': 'properties.lastName', 'type': 'str'}, } - def __init__(self, *, state="active", note: str=None, identities=None, email: str=None, password: str=None, first_name: str=None, last_name: str=None, **kwargs) -> None: + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + email: Optional[str] = None, + password: Optional[str] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + **kwargs + ): super(UserUpdateParameters, self).__init__(**kwargs) self.state = state self.note = note @@ -7828,20 +12183,74 @@ def __init__(self, *, state="active", note: str=None, identities=None, email: st self.last_name = last_name -class VirtualNetworkConfiguration(Model): - """Configuration of a virtual network to which API Management service is - deployed. +class UserUpdateParametersProperties(UserEntityBaseParameters): + """Parameters supplied to the Update User operation. + + :param state: Account state. Specifies whether the user is active or not. Blocked users are + unable to sign into the developer portal or call any APIs of subscribed products. Default state + is Active. Possible values include: "active", "blocked", "pending", "deleted". Default value: + "active". + :type state: str or ~azure.mgmt.apimanagement.models.UserState + :param note: Optional note about a user set by the administrator. + :type note: str + :param identities: Collection of user identities. + :type identities: list[~azure.mgmt.apimanagement.models.UserIdentityContract] + :param email: Email address. Must not be empty and must be unique within the service instance. + :type email: str + :param password: User Password. + :type password: str + :param first_name: First name. + :type first_name: str + :param last_name: Last name. + :type last_name: str + """ + + _validation = { + 'email': {'max_length': 254, 'min_length': 1}, + 'first_name': {'max_length': 100, 'min_length': 1}, + 'last_name': {'max_length': 100, 'min_length': 1}, + } + + _attribute_map = { + 'state': {'key': 'state', 'type': 'str'}, + 'note': {'key': 'note', 'type': 'str'}, + 'identities': {'key': 'identities', 'type': '[UserIdentityContract]'}, + 'email': {'key': 'email', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + 'first_name': {'key': 'firstName', 'type': 'str'}, + 'last_name': {'key': 'lastName', 'type': 'str'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "UserState"]] = "active", + note: Optional[str] = None, + identities: Optional[List["UserIdentityContract"]] = None, + email: Optional[str] = None, + password: Optional[str] = None, + first_name: Optional[str] = None, + last_name: Optional[str] = None, + **kwargs + ): + super(UserUpdateParametersProperties, self).__init__(state=state, note=note, identities=identities, **kwargs) + self.email = email + self.password = password + self.first_name = first_name + self.last_name = last_name + + +class VirtualNetworkConfiguration(msrest.serialization.Model): + """Configuration of a virtual network to which API Management service is deployed. - Variables are only populated by the server, and will be ignored when - sending a request. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a - null GUID by default. + :ivar vnetid: The virtual network ID. This is typically a GUID. Expect a null GUID by default. :vartype vnetid: str :ivar subnetname: The name of the subnet. :vartype subnetname: str - :param subnet_resource_id: The full resource ID of a subnet in a virtual - network to deploy the API Management service in. + :param subnet_resource_id: The full resource ID of a subnet in a virtual network to deploy the + API Management service in. :type subnet_resource_id: str """ @@ -7857,20 +12266,24 @@ class VirtualNetworkConfiguration(Model): 'subnet_resource_id': {'key': 'subnetResourceId', 'type': 'str'}, } - def __init__(self, *, subnet_resource_id: str=None, **kwargs) -> None: + def __init__( + self, + *, + subnet_resource_id: Optional[str] = None, + **kwargs + ): super(VirtualNetworkConfiguration, self).__init__(**kwargs) self.vnetid = None self.subnetname = None self.subnet_resource_id = subnet_resource_id -class X509CertificateName(Model): +class X509CertificateName(msrest.serialization.Model): """Properties of server X509Names. :param name: Common Name of the Certificate. :type name: str - :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the - Certificate. + :param issuer_certificate_thumbprint: Thumbprint for the Issuer of the Certificate. :type issuer_certificate_thumbprint: str """ @@ -7879,7 +12292,13 @@ class X509CertificateName(Model): 'issuer_certificate_thumbprint': {'key': 'issuerCertificateThumbprint', 'type': 'str'}, } - def __init__(self, *, name: str=None, issuer_certificate_thumbprint: str=None, **kwargs) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + issuer_certificate_thumbprint: Optional[str] = None, + **kwargs + ): super(X509CertificateName, self).__init__(**kwargs) self.name = name self.issuer_certificate_thumbprint = issuer_certificate_thumbprint diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_paged_models.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_paged_models.py deleted file mode 100644 index bc1ee244cc6c..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/models/_paged_models.py +++ /dev/null @@ -1,482 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -from msrest.paging import Paged - - -class ApiContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ApiContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApiContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ApiContractPaged, self).__init__(*args, **kwargs) -class TagResourceContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagResourceContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagResourceContract]'} - } - - def __init__(self, *args, **kwargs): - - super(TagResourceContractPaged, self).__init__(*args, **kwargs) -class ApiRevisionContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ApiRevisionContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApiRevisionContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ApiRevisionContractPaged, self).__init__(*args, **kwargs) -class ApiReleaseContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ApiReleaseContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApiReleaseContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ApiReleaseContractPaged, self).__init__(*args, **kwargs) -class OperationContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`OperationContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[OperationContract]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationContractPaged, self).__init__(*args, **kwargs) -class TagContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagContract]'} - } - - def __init__(self, *args, **kwargs): - - super(TagContractPaged, self).__init__(*args, **kwargs) -class ProductContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ProductContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ProductContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ProductContractPaged, self).__init__(*args, **kwargs) -class SchemaContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`SchemaContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[SchemaContract]'} - } - - def __init__(self, *args, **kwargs): - - super(SchemaContractPaged, self).__init__(*args, **kwargs) -class DiagnosticContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`DiagnosticContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[DiagnosticContract]'} - } - - def __init__(self, *args, **kwargs): - - super(DiagnosticContractPaged, self).__init__(*args, **kwargs) -class IssueContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`IssueContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[IssueContract]'} - } - - def __init__(self, *args, **kwargs): - - super(IssueContractPaged, self).__init__(*args, **kwargs) -class IssueCommentContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`IssueCommentContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[IssueCommentContract]'} - } - - def __init__(self, *args, **kwargs): - - super(IssueCommentContractPaged, self).__init__(*args, **kwargs) -class IssueAttachmentContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`IssueAttachmentContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[IssueAttachmentContract]'} - } - - def __init__(self, *args, **kwargs): - - super(IssueAttachmentContractPaged, self).__init__(*args, **kwargs) -class TagDescriptionContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`TagDescriptionContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[TagDescriptionContract]'} - } - - def __init__(self, *args, **kwargs): - - super(TagDescriptionContractPaged, self).__init__(*args, **kwargs) -class ApiVersionSetContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ApiVersionSetContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApiVersionSetContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ApiVersionSetContractPaged, self).__init__(*args, **kwargs) -class AuthorizationServerContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`AuthorizationServerContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[AuthorizationServerContract]'} - } - - def __init__(self, *args, **kwargs): - - super(AuthorizationServerContractPaged, self).__init__(*args, **kwargs) -class BackendContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`BackendContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[BackendContract]'} - } - - def __init__(self, *args, **kwargs): - - super(BackendContractPaged, self).__init__(*args, **kwargs) -class CacheContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`CacheContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[CacheContract]'} - } - - def __init__(self, *args, **kwargs): - - super(CacheContractPaged, self).__init__(*args, **kwargs) -class CertificateContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`CertificateContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[CertificateContract]'} - } - - def __init__(self, *args, **kwargs): - - super(CertificateContractPaged, self).__init__(*args, **kwargs) -class OperationPaged(Paged): - """ - A paging container for iterating over a list of :class:`Operation ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[Operation]'} - } - - def __init__(self, *args, **kwargs): - - super(OperationPaged, self).__init__(*args, **kwargs) -class ResourceSkuResultPaged(Paged): - """ - A paging container for iterating over a list of :class:`ResourceSkuResult ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ResourceSkuResult]'} - } - - def __init__(self, *args, **kwargs): - - super(ResourceSkuResultPaged, self).__init__(*args, **kwargs) -class ApiManagementServiceResourcePaged(Paged): - """ - A paging container for iterating over a list of :class:`ApiManagementServiceResource ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ApiManagementServiceResource]'} - } - - def __init__(self, *args, **kwargs): - - super(ApiManagementServiceResourcePaged, self).__init__(*args, **kwargs) -class EmailTemplateContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`EmailTemplateContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[EmailTemplateContract]'} - } - - def __init__(self, *args, **kwargs): - - super(EmailTemplateContractPaged, self).__init__(*args, **kwargs) -class GatewayContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`GatewayContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GatewayContract]'} - } - - def __init__(self, *args, **kwargs): - - super(GatewayContractPaged, self).__init__(*args, **kwargs) -class GatewayHostnameConfigurationContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`GatewayHostnameConfigurationContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GatewayHostnameConfigurationContract]'} - } - - def __init__(self, *args, **kwargs): - - super(GatewayHostnameConfigurationContractPaged, self).__init__(*args, **kwargs) -class GroupContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`GroupContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[GroupContract]'} - } - - def __init__(self, *args, **kwargs): - - super(GroupContractPaged, self).__init__(*args, **kwargs) -class UserContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`UserContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[UserContract]'} - } - - def __init__(self, *args, **kwargs): - - super(UserContractPaged, self).__init__(*args, **kwargs) -class IdentityProviderContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`IdentityProviderContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[IdentityProviderContract]'} - } - - def __init__(self, *args, **kwargs): - - super(IdentityProviderContractPaged, self).__init__(*args, **kwargs) -class LoggerContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`LoggerContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[LoggerContract]'} - } - - def __init__(self, *args, **kwargs): - - super(LoggerContractPaged, self).__init__(*args, **kwargs) -class NamedValueContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`NamedValueContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[NamedValueContract]'} - } - - def __init__(self, *args, **kwargs): - - super(NamedValueContractPaged, self).__init__(*args, **kwargs) -class NotificationContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`NotificationContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[NotificationContract]'} - } - - def __init__(self, *args, **kwargs): - - super(NotificationContractPaged, self).__init__(*args, **kwargs) -class OpenidConnectProviderContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`OpenidConnectProviderContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[OpenidConnectProviderContract]'} - } - - def __init__(self, *args, **kwargs): - - super(OpenidConnectProviderContractPaged, self).__init__(*args, **kwargs) -class SubscriptionContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`SubscriptionContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[SubscriptionContract]'} - } - - def __init__(self, *args, **kwargs): - - super(SubscriptionContractPaged, self).__init__(*args, **kwargs) -class RegionContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`RegionContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RegionContract]'} - } - - def __init__(self, *args, **kwargs): - - super(RegionContractPaged, self).__init__(*args, **kwargs) -class ReportRecordContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`ReportRecordContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ReportRecordContract]'} - } - - def __init__(self, *args, **kwargs): - - super(ReportRecordContractPaged, self).__init__(*args, **kwargs) -class RequestReportRecordContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`RequestReportRecordContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[RequestReportRecordContract]'} - } - - def __init__(self, *args, **kwargs): - - super(RequestReportRecordContractPaged, self).__init__(*args, **kwargs) -class UserIdentityContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`UserIdentityContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[UserIdentityContract]'} - } - - def __init__(self, *args, **kwargs): - - super(UserIdentityContractPaged, self).__init__(*args, **kwargs) 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 2dae331a8203..60aa39dc2ad2 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 @@ -1,12 +1,9 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from ._api_operations import ApiOperations @@ -24,12 +21,16 @@ from ._api_issue_attachment_operations import ApiIssueAttachmentOperations from ._api_tag_description_operations import ApiTagDescriptionOperations from ._operation_operations import OperationOperations +from ._api_export_operations import ApiExportOperations from ._api_version_set_operations import ApiVersionSetOperations from ._authorization_server_operations import AuthorizationServerOperations from ._backend_operations import BackendOperations from ._cache_operations import CacheOperations from ._certificate_operations import CertificateOperations -from ._api_management_operations import ApiManagementOperations +from ._content_type_operations import ContentTypeOperations +from ._content_type_content_item_operations import ContentTypeContentItemOperations +from ._deleted_services_operations import DeletedServicesOperations +from ._api_management_operations_operations import ApiManagementOperationsOperations from ._api_management_service_skus_operations import ApiManagementServiceSkusOperations from ._api_management_service_operations import ApiManagementServiceOperations from ._diagnostic_operations import DiagnosticOperations @@ -72,7 +73,6 @@ from ._user_subscription_operations import UserSubscriptionOperations from ._user_identities_operations import UserIdentitiesOperations from ._user_confirmation_password_operations import UserConfirmationPasswordOperations -from ._api_export_operations import ApiExportOperations __all__ = [ 'ApiOperations', @@ -90,12 +90,16 @@ 'ApiIssueAttachmentOperations', 'ApiTagDescriptionOperations', 'OperationOperations', + 'ApiExportOperations', 'ApiVersionSetOperations', 'AuthorizationServerOperations', 'BackendOperations', 'CacheOperations', 'CertificateOperations', - 'ApiManagementOperations', + 'ContentTypeOperations', + 'ContentTypeContentItemOperations', + 'DeletedServicesOperations', + 'ApiManagementOperationsOperations', 'ApiManagementServiceSkusOperations', 'ApiManagementServiceOperations', 'DiagnosticOperations', @@ -138,5 +142,4 @@ 'UserSubscriptionOperations', 'UserIdentitiesOperations', 'UserConfirmationPasswordOperations', - 'ApiExportOperations', ] 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 57f5d5b49878..eafebbe09e35 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,494 +1,529 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiDiagnosticOperations(object): """ApiDiagnosticOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DiagnosticCollection"] """Lists all diagnostics of an API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DiagnosticContract - :rtype: - ~azure.mgmt.apimanagement.models.DiagnosticContractPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DiagnosticContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, diagnostic_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Diagnostic for an API - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + diagnostic_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} + 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 def get( - self, resource_group_name, service_name, api_id, diagnostic_id, custom_headers=None, raw=False, **operation_config): - """Gets the details of the Diagnostic for an API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + diagnostic_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DiagnosticContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, diagnostic_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + diagnostic_id, # type: str + parameters, # type: "models.DiagnosticContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DiagnosticContract" """Creates a new Diagnostic for an API or updates an existing one. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DiagnosticContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'DiagnosticContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore def update( - self, resource_group_name, service_name, api_id, diagnostic_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): - """Updates the details of the Diagnostic for an API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + diagnostic_id, # type: str + if_match, # type: str + parameters, # type: "models.DiagnosticContract" + **kwargs # type: Any + ): + # type: (...) -> "models.DiagnosticContract" + """Updates the details of the Diagnostic for an API 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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str :param parameters: Diagnostic Update parameters. :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract - :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, diagnostic_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + diagnostic_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified Diagnostic from an API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}'} + 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 ab05e246f647..e9816121d082 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,113 +1,120 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiExportOperations(object): """ApiExportOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar export: Query parameter required to export the API details. Constant value: "true". - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.export = "true" - self.api_version = "2019-12-01" - - self.config = config + self._config = config def get( - self, resource_group_name, service_name, api_id, format, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + format, # type: Union[str, "models.ExportFormat"] + export, # type: Union[str, "models.ExportApi"] + **kwargs # type: Any + ): + # type: (...) -> "models.ApiExportResult" + """Gets the details of the API specified by its identifier in the format specified to the Storage + Blob with SAS Key valid for 5 minutes. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param format: Format in which to export the Api Details to the - Storage Blob with Sas Key valid for 5 minutes. Possible values - include: 'Swagger', 'Wsdl', 'Wadl', 'Openapi', 'OpenapiJson' + :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 ~azure.mgmt.apimanagement.models.ExportFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiExportResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiExportResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param export: Query parameter required to export the API details. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['export'] = self._serialize.query("self.export", self.export, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['export'] = self._serialize.query("export", export, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiExportResult', response) + deserialized = self._deserialize('ApiExportResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + 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 91257c1171a5..28729e474915 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,445 +1,472 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiIssueAttachmentOperations(object): """ApiIssueAttachmentOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, issue_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.IssueAttachmentCollection"] """Lists all attachments for the Issue associated with the specified API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of IssueAttachmentContract - :rtype: - ~azure.mgmt.apimanagement.models.IssueAttachmentContractPaged[~azure.mgmt.apimanagement.models.IssueAttachmentContract] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either IssueAttachmentCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.IssueAttachmentCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueAttachmentCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('IssueAttachmentCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.IssueAttachmentContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, issue_id, attachment_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the issue Attachment for an API - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + attachment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the issue Attachment for an API specified by its + identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be - unique in the current Issue. + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. :type attachment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, issue_id, attachment_id, custom_headers=None, raw=False, **operation_config): - """Gets the details of the issue Attachment for an API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + attachment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.IssueAttachmentContract" + """Gets the details of the issue Attachment for an API 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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be - unique in the current Issue. + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. :type attachment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueAttachmentContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueAttachmentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueAttachmentContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('IssueAttachmentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, issue_id, attachment_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates a new Attachment for the Issue in an API or updates an existing - one. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + attachment_id, # type: str + parameters, # type: "models.IssueAttachmentContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.IssueAttachmentContract" + """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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be - unique in the current Issue. + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. :type attachment_id: str :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueAttachmentContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueAttachmentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueAttachmentContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueAttachmentContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IssueAttachmentContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('IssueAttachmentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('IssueAttachmentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueAttachmentContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, issue_id, attachment_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + attachment_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified comment from an Issue. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param attachment_id: Attachment identifier within an Issue. Must be - unique in the current Issue. + :param attachment_id: Attachment identifier within an Issue. Must be unique in the current + Issue. :type attachment_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'attachmentId': self._serialize.url("attachment_id", attachment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}'} + 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 513853155a04..58a28c11597e 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,445 +1,468 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiIssueCommentOperations(object): """ApiIssueCommentOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, issue_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.IssueCommentCollection"] """Lists all comments for the Issue associated with the specified API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of IssueCommentContract - :rtype: - ~azure.mgmt.apimanagement.models.IssueCommentContractPaged[~azure.mgmt.apimanagement.models.IssueCommentContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.IssueCommentCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCommentCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCommentCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.IssueCommentContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, issue_id, comment_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the issue Comment for an API - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + comment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the issue Comment for an API specified by its + identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique - in the current Issue. + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. :type comment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, issue_id, comment_id, custom_headers=None, raw=False, **operation_config): - """Gets the details of the issue Comment for an API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + comment_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.IssueCommentContract" + """Gets the details of the issue Comment for an API 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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique - in the current Issue. + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. :type comment_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueCommentContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueCommentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCommentContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('IssueCommentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, issue_id, comment_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates a new Comment for the Issue in an API or updates an existing - one. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + comment_id, # type: str + parameters, # type: "models.IssueCommentContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.IssueCommentContract" + """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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique - in the current Issue. + :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: - ~azure.mgmt.apimanagement.models.IssueCommentContract - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueCommentContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueCommentContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueCommentContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCommentContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IssueCommentContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('IssueCommentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('IssueCommentContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueCommentContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, issue_id, comment_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + comment_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified comment from an Issue. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param comment_id: Comment identifier within an Issue. Must be unique - in the current Issue. + :param comment_id: Comment identifier within an Issue. Must be unique in the current Issue. :type comment_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'commentId': self._serialize.url("comment_id", comment_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}'} + 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 36d063df0a8e..84dd15367803 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,61 +1,75 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiIssueOperations(object): """ApiIssueOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, filter=None, expand_comments_attachments=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + expand_comments_attachments=None, # type: Optional[bool] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.IssueCollection"] """Lists all issues associated with the specified API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| state | filter - | eq | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | + filter | eq | |
. :type filter: str :param expand_comments_attachments: Expand the comment attachments. :type expand_comments_attachments: bool @@ -63,31 +77,36 @@ def list_by_service( :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of IssueContract - :rtype: - ~azure.mgmt.apimanagement.models.IssueContractPaged[~azure.mgmt.apimanagement.models.IssueContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.IssueCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if expand_comments_attachments is not None: @@ -96,407 +115,427 @@ def prepare_request(next_link=None): query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.IssueContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, issue_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Issue for an API specified - by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Issue for an API specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} + 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 def get( - self, resource_group_name, service_name, api_id, issue_id, expand_comments_attachments=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + expand_comments_attachments=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> "models.IssueContract" """Gets the details of the Issue for an API 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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :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. :type expand_comments_attachments: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if expand_comments_attachments is not None: query_parameters['expandCommentsAttachments'] = self._serialize.query("expand_comments_attachments", expand_comments_attachments, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('IssueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, issue_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + parameters, # type: "models.IssueContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.IssueContract" """Creates a new Issue for an API or updates an existing one. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IssueContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('IssueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('IssueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore def update( - self, resource_group_name, service_name, api_id, issue_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + if_match, # type: str + parameters, # type: "models.IssueUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.IssueContract" """Updates an existing issue for an API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str :param parameters: Update parameters. :type parameters: ~azure.mgmt.apimanagement.models.IssueUpdateContract - :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IssueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, issue_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + issue_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified Issue from an API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}'} + 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_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations.py deleted file mode 100644 index e221fb1e1faa..000000000000 --- a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class ApiManagementOperations(object): - """ApiManagementOperations operations. - - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config - - def list( - self, custom_headers=None, raw=False, **operation_config): - """Lists all of the available REST API operations of the - Microsoft.ApiManagement provider. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of Operation - :rtype: - ~azure.mgmt.apimanagement.models.OperationPaged[~azure.mgmt.apimanagement.models.Operation] - :raises: :class:`CloudError` - """ - def prepare_request(next_link=None): - if not next_link: - # Construct URL - url = self.list.metadata['url'] - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) - return request - - def internal_paging(next_link=None): - request = prepare_request(next_link) - - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response - - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/providers/Microsoft.ApiManagement/operations'} 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 new file mode 100644 index 000000000000..aefd73d9adec --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_management_operations_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ApiManagementOperationsOperations(object): + """ApiManagementOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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[~azure.mgmt.apimanagement.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + 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 7daa7858229f..a883421621eb 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,982 +1,1112 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiManagementServiceOperations(object): """ApiManagementServiceOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config - + self._config = config def _restore_initial( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceBackupRestoreParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.restore.metadata['url'] + url = self._restore_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def restore( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """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. + _restore_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore + + def begin_restore( + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceBackupRestoreParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] + """Restores a backup of an API Management service created using the ApiManagementService_Backup + operation on the current service. This is a long running operation and could take several + minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param parameters: Parameters supplied to the Restore API Management - service from backup operation. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the Restore API Management service from backup + operation. + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._restore_initial( - resource_group_name=resource_group_name, - service_name=service_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._restore_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore'} # type: ignore def _backup_initial( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceBackupRestoreParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.backup.metadata['url'] + url = self._backup_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceBackupRestoreParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def backup( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """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. + _backup_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore + + def begin_backup( + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceBackupRestoreParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] + """Creates a backup of the API Management service to the given Azure Storage Account. This is long + running operation and could take several minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :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: - ~azure.mgmt.apimanagement.models.ApiManagementServiceBackupRestoreParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the ApiManagementService_Backup operation. + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._backup_initial( - resource_group_name=resource_group_name, - service_name=service_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._backup_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_backup.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup'} # type: ignore def _create_or_update_initial( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceResource" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiManagementServiceResource') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def create_or_update( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): - """Creates or updates an API Management service. This is long running - operation and could take several minutes to complete. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceResource" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] + """Creates or updates an API Management service. This is long running operation and could take + several minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :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: - ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore def _update_initial( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ApiManagementServiceUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def update( - self, resource_group_name, service_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.ApiManagementServiceUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] """Updates an existing API Management service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param parameters: Parameters supplied to the CreateOrUpdate API - Management service operation. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiManagementServiceUpdateParameters - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Parameters supplied to the CreateOrUpdate API Management service operation. + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - parameters=parameters, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiManagementServiceResource" """Gets an API Management service resource description. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiManagementServiceResource or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiManagementServiceResource, or the result of cls(response) :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceResource - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore def _delete_initial( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self._delete_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 202: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def delete( - self, resource_group_name, service_name, custom_headers=None, raw=False, polling=True, **operation_config): + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore + + def begin_delete( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] """Deletes an existing API Management service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._delete_initial( - resource_group_name=resource_group_name, - service_name=service_name, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + service_name=service_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}'} # type: ignore def list_by_resource_group( - self, resource_group_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiManagementServiceListResult"] """List all API Management services within a resource group. :param resource_group_name: The name of the resource group. :type resource_group_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiManagementServiceResource - :rtype: - ~azure.mgmt.apimanagement.models.ApiManagementServiceResourcePaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiManagementServiceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_resource_group.metadata['url'] + url = self.list_by_resource_group.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiManagementServiceResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service'} # type: ignore def list( - self, custom_headers=None, raw=False, **operation_config): + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiManagementServiceListResult"] """Lists all API Management services within an Azure subscription. - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiManagementServiceResource - :rtype: - ~azure.mgmt.apimanagement.models.ApiManagementServiceResourcePaged[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - :raises: :class:`CloudError` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ApiManagementServiceListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ApiManagementServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiManagementServiceResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service'} # type: ignore def get_sso_token( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): - """Gets the Single-Sign-On token for the API Management Service which is - valid for 5 Minutes. + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiManagementServiceGetSsoTokenResult or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiManagementServiceGetSsoTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceGetSsoTokenResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceGetSsoTokenResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_sso_token.metadata['url'] + url = self.get_sso_token.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', response) + deserialized = self._deserialize('ApiManagementServiceGetSsoTokenResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} + get_sso_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken'} # type: ignore def check_name_availability( - self, name, custom_headers=None, raw=False, **operation_config): - """Checks availability and correctness of a name for an API Management - service. + self, + name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiManagementServiceNameAvailabilityResult" + """Checks availability and correctness of a name for an API Management service. :param name: The name to check for availability. :type name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiManagementServiceNameAvailabilityResult or - ClientRawResponse if raw=true - :rtype: - ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiManagementServiceNameAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiManagementServiceNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ApiManagementServiceCheckNameAvailabilityParameters(name=name) + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceNameAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiManagementServiceCheckNameAvailabilityParameters(name=name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.check_name_availability.metadata['url'] + url = self.check_name_availability.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiManagementServiceCheckNameAvailabilityParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', response) + deserialized = self._deserialize('ApiManagementServiceNameAvailabilityResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} - + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability'} # type: ignore def _apply_network_configuration_updates_initial( - self, resource_group_name, service_name, location=None, custom_headers=None, raw=False, **operation_config): - parameters = None - if location is not None: - parameters = models.ApiManagementServiceApplyNetworkConfigurationParameters(location=location) + self, + resource_group_name, # type: str + service_name, # type: str + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiManagementServiceResource"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiManagementServiceResource"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiManagementServiceApplyNetworkConfigurationParameters(location=location) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.apply_network_configuration_updates.metadata['url'] + url = self._apply_network_configuration_updates_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - if parameters is not None: - body_content = self._serialize.body(parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'ApiManagementServiceApplyNetworkConfigurationParameters') else: body_content = None - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiManagementServiceResource', response) + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def apply_network_configuration_updates( - self, resource_group_name, service_name, location=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Updates the Microsoft.ApiManagement resource running in the Virtual - network to pick the updated network settings. + _apply_network_configuration_updates_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} # type: ignore + + def begin_apply_network_configuration_updates( + self, + resource_group_name, # type: str + service_name, # type: str + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiManagementServiceResource"] + """Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated + network 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 location: Location of the Api Management service to update for - a multi-region service. For a service deployed in a single region, - this parameter is not required. + :param location: Location of the Api Management service to update for a multi-region service. + For a service deployed in a single region, this parameter is not required. :type location: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns - ApiManagementServiceResource or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiManagementServiceResource]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiManagementServiceResource or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiManagementServiceResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._apply_network_configuration_updates_initial( - resource_group_name=resource_group_name, - service_name=service_name, - location=location, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiManagementServiceResource"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('ApiManagementServiceResource', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._apply_network_configuration_updates_initial( + resource_group_name=resource_group_name, + service_name=service_name, + location=location, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ApiManagementServiceResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - apply_network_configuration_updates.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_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 bfe3b31eb23d..069df9675116 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,45 +1,57 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiManagementServiceSkusOperations(object): """ApiManagementServiceSkusOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_available_service_skus( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ResourceSkuResults"] """Gets available SKUs for API Management service. Gets all available SKU for a given API Management service. @@ -48,65 +60,65 @@ def list_available_service_skus( :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ResourceSkuResult - :rtype: - ~azure.mgmt.apimanagement.models.ResourceSkuResultPaged[~azure.mgmt.apimanagement.models.ResourceSkuResult] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ResourceSkuResults] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ResourceSkuResults"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_available_service_skus.metadata['url'] + url = self.list_available_service_skus.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ResourceSkuResults', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ResourceSkuResultPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_available_service_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus'} + return ItemPaged( + get_next, extract_data + ) + 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_operation_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_api_operation_operations.py index 547d6e392dcb..0908c3542863 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,66 +1,79 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiOperationOperations(object): """ApiOperationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_api( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, tags=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + tags=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationCollection"] """Lists a collection of the operations for the specified API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| method | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| description | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| urlTemplate | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int @@ -68,31 +81,36 @@ def list_by_api( :type skip: int :param tags: Include tags in the response. :type tags: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of OperationContract - :rtype: - ~azure.mgmt.apimanagement.models.OperationContractPaged[~azure.mgmt.apimanagement.models.OperationContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.OperationCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_api.metadata['url'] + url = self.list_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -101,410 +119,427 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if tags is not None: query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OperationContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the API operation specified by - its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the API operation specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} + 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 def get( - self, resource_group_name, service_name, api_id, operation_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.OperationContract" """Gets the details of the API Operation 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OperationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.OperationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, operation_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + parameters, # type: "models.OperationContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.OperationContract" """Creates a new operation in the API or updates an existing one. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OperationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.OperationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.OperationContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'OperationContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OperationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('OperationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore def update( - self, resource_group_name, service_name, api_id, operation_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): - """Updates the details of the operation in the API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + if_match, # type: str + parameters, # type: "models.OperationUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.OperationContract" + """Updates the details of the operation in the API 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param parameters: API Operation Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.OperationUpdateContract - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: API Operation Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'OperationUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OperationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, operation_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified operation in the API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}'} + 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 522445c42c20..ded6d6505912 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,421 +1,447 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiOperationPolicyOperations(object): """ApiOperationPolicyOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar policy_id: The identifier of the Policy. Constant value: "policy". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.policy_id = "policy" - - self.config = config + self._config = config def list_by_operation( - self, resource_group_name, service_name, api_id, operation_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyCollection" """Get the list of policy configuration at the API Operation level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_operation.metadata['url'] + url = self.list_by_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyCollection', response) + deserialized = self._deserialize('PolicyCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} + list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, api_id, operation_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the API operation policy - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the API operation policy specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, operation_id, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + format="xml", # type: Optional[Union[str, "models.PolicyExportFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Get the policy configuration at the API Operation level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param format: Policy Export Format. Possible values include: 'xml', - 'rawxml' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyExportFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if format is not None: query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, operation_id, value, if_match=None, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match=None, # type: Optional[str] + value=None, # type: Optional[str] + format="xml", # type: Optional[Union[str, "models.PolicyContentFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Creates or updates policy configuration for the API Operation level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str :param value: Contents of the Policy as defined by the format. :type value: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. - :type if_match: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyContentFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PolicyContract(value=value, format=format) + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyContract') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, operation_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the policy configuration at the Api Operation. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param policy_id: The identifier of the Policy. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}'} + 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 17e65e2bf741..5583cc926fbe 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,64 +1,78 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiOperations(object): """ApiOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, tags=None, expand_api_version_set=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + tags=None, # type: Optional[str] + expand_api_version_set=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiCollection"] """Lists all APIs of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| path | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| isCurrent | filter | eq, ne | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -66,33 +80,37 @@ def list_by_service( :type skip: int :param tags: Include tags in the response. :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. :type expand_api_version_set: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiContractPaged[~azure.mgmt.apimanagement.models.ApiContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -103,461 +121,503 @@ def prepare_request(next_link=None): query_parameters['tags'] = self._serialize.query("tags", tags, 'str') if expand_api_version_set is not None: query_parameters['expandApiVersionSet'] = self._serialize.query("expand_api_version_set", expand_api_version_set, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, api_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the API 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiContract" """Gets the details of the API 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json, application/vnd.swagger.doc+json, application/vnd.oai.openapi+json, application/vnd.sun.wadl+xml, application/wsdl+xml" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + if response.status_code not in [200, 200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ApiContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, service_name, api_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + parameters, # type: "models.ApiCreateOrUpdateParameter" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ApiContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ApiContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ApiCreateOrUpdateParameter') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('ApiContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - - def create_or_update( - self, resource_group_name, service_name, api_id, parameters, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Creates new or updates existing specified API of the API Management - service instance. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + parameters, # type: "models.ApiCreateOrUpdateParameter" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ApiContract"] + """Creates new or updates existing specified API of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str :param parameters: Create or update parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns ApiContract or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.ApiContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.ApiContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ApiContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.ApiContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - parameters=parameters, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - header_dict = { - 'ETag': 'str', - } - deserialized = self._deserialize('ApiContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore def update( - self, resource_group_name, service_name, api_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + if_match, # type: str + parameters, # type: "models.ApiUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.ApiContract" """Updates the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str + :param if_match: ETag of 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: API Update Contract parameters. :type parameters: ~azure.mgmt.apimanagement.models.ApiUpdateContract - :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ApiUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, if_match, delete_revisions=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + if_match, # type: str + delete_revisions=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified API of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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. :type delete_revisions: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if delete_revisions is not None: query_parameters['deleteRevisions'] = self._serialize.query("delete_revisions", delete_revisions, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}'} # type: ignore def list_by_tags( - self, resource_group_name, service_name, filter=None, top=None, skip=None, include_not_tagged_apis=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + include_not_tagged_apis=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagResourceCollection"] """Lists a collection of apis associated with tags. :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 | Supported operators | Supported - functions | - |-------------|------------------------|-----------------------------------| - |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith| - |displayName | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith| - |apiRevision | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith| - |path | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith| - |description | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith| - |serviceUrl | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith| - |isCurrent | eq | | + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| isCurrent | filter | eq | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -565,30 +625,35 @@ def list_by_tags( :type skip: int :param include_not_tagged_apis: Include not tagged APIs. :type include_not_tagged_apis: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagResourceContract - :rtype: - ~azure.mgmt.apimanagement.models.TagResourceContractPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_tags.metadata['url'] + url = self.list_by_tags.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -597,41 +662,36 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if include_not_tagged_apis is not None: query_parameters['includeNotTaggedApis'] = self._serialize.query("include_not_tagged_apis", include_not_tagged_apis, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagResourceContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags'} + return ItemPaged( + get_next, extract_data + ) + 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 195c7415eb56..824cd331f28b 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,401 +1,427 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiPolicyOperations(object): """ApiPolicyOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar policy_id: The identifier of the Policy. Constant value: "policy". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.policy_id = "policy" - - self.config = config + self._config = config def list_by_api( - self, resource_group_name, service_name, api_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyCollection" """Get the policy configuration at the API level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_api.metadata['url'] + url = self.list_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyCollection', response) + deserialized = self._deserialize('PolicyCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, api_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the API policy specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the API 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + format="xml", # type: Optional[Union[str, "models.PolicyExportFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Get the policy configuration at the API level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param format: Policy Export Format. Possible values include: 'xml', - 'rawxml' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyExportFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if format is not None: query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + if response.status_code not in [200, 200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - header_dict = {} - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, value, if_match=None, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match=None, # type: Optional[str] + value=None, # type: Optional[str] + format="xml", # type: Optional[Union[str, "models.PolicyContentFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Creates or updates policy configuration for the API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str :param value: Contents of the Policy as defined by the format. :type value: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. - :type if_match: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyContentFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PolicyContract(value=value, format=format) + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyContract') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the policy configuration at the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param policy_id: The identifier of the Policy. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}'} + 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 14b7f8245e8a..8181d8029d1e 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,130 +1,143 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiProductOperations(object): """ApiProductOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_apis( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductCollection"] """Lists all Products, which the API is part of. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| displayName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ProductContract - :rtype: - ~azure.mgmt.apimanagement.models.ProductContractPaged[~azure.mgmt.apimanagement.models.ProductContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ProductCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_apis.metadata['url'] + url = self.list_by_apis.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProductContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_apis.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products'} + 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 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 4ad883413357..cc1ca272449a 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,503 +1,541 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiReleaseOperations(object): """ApiReleaseOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiReleaseCollection"] + """Lists all releases of an API. An API release is created when making an API Revision current. + Releases are also used to rollback to previous revisions. Results will be paged and can be + constrained by the $top and $skip parameters. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - notes | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| notes | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiReleaseContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiReleaseContractPaged[~azure.mgmt.apimanagement.models.ApiReleaseContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiReleaseCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiReleaseCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiReleaseContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, release_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + release_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Returns the etag of an API release. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param release_id: Release identifier within an API. Must be unique in - the current API Management service instance. + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. :type release_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} + 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 def get( - self, resource_group_name, service_name, api_id, release_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + release_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiReleaseContract" """Returns the details of an API release. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param release_id: Release identifier within an API. Must be unique in - the current API Management service instance. + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. :type release_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiReleaseContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiReleaseContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, release_id, if_match=None, api_id1=None, notes=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + release_id, # type: str + if_match=None, # type: Optional[str] + api_release_contract_properties_api_id=None, # type: Optional[str] + notes=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ApiReleaseContract" """Creates a new Release for the API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param release_id: Release identifier within an API. Must be unique in - the current API Management service instance. + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. :type release_id: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param api_id1: Identifier of the API the release belongs to. - :type api_id1: str - :param notes: Release Notes + :param api_release_contract_properties_api_id: Identifier of the API the release belongs to. + :type api_release_contract_properties_api_id: str + :param notes: Release Notes. :type notes: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiReleaseContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ApiReleaseContract(api_id=api_id1, notes=notes) + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiReleaseContract(api_id=api_release_contract_properties_api_id, notes=notes) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'ApiReleaseContract') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiReleaseContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ApiReleaseContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiReleaseContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore def update( - self, resource_group_name, service_name, api_id, release_id, if_match, api_id1=None, notes=None, custom_headers=None, raw=False, **operation_config): - """Updates the details of the release of the API specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + release_id, # type: str + if_match, # type: str + api_release_contract_properties_api_id=None, # type: Optional[str] + notes=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param release_id: Release identifier within an API. Must be unique in - the current API Management service instance. + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. :type release_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 api_id1: Identifier of the API the release belongs to. - :type api_id1: str - :param notes: Release Notes + :param api_release_contract_properties_api_id: Identifier of the API the release belongs to. + :type api_release_contract_properties_api_id: str + :param notes: Release Notes. :type notes: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiReleaseContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiReleaseContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.ApiReleaseContract(api_id=api_id1, notes=notes) + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiReleaseContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.ApiReleaseContract(api_id=api_release_contract_properties_api_id, notes=notes) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body - body_content = self._serialize.body(parameters, 'ApiReleaseContract') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'ApiReleaseContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiReleaseContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, release_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + release_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified release in the API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param release_id: Release identifier within an API. Must be unique in - the current API Management service instance. + :param release_id: Release identifier within an API. Must be unique in the current API + Management service instance. :type release_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), 'releaseId': self._serialize.url("release_id", release_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}'} + 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 c69ddf7d3e3e..14d4b0894d36 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,130 +1,143 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiRevisionOperations(object): """ApiRevisionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiRevisionCollection"] """Lists all revisions of an API. :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 api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| apiRevision + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiRevisionContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiRevisionContractPaged[~azure.mgmt.apimanagement.models.ApiRevisionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiRevisionCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiRevisionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiRevisionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiRevisionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions'} + 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 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 d681f90359af..14b64aa78a95 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,473 +1,520 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiSchemaOperations(object): """ApiSchemaOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_api( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SchemaCollection"] """Get the schema configuration at the API level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - contentType | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| contentType + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of SchemaContract - :rtype: - ~azure.mgmt.apimanagement.models.SchemaContractPaged[~azure.mgmt.apimanagement.models.SchemaContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.SchemaCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SchemaCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_api.metadata['url'] + url = self.list_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SchemaCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SchemaContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, schema_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the schema specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + schema_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the schema specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in - the current API Management service instance. + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. :type schema_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} + 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 def get( - self, resource_group_name, service_name, api_id, schema_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + schema_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.SchemaContract" """Get the schema configuration at the API level. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in - the current API Management service instance. + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. :type schema_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SchemaContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.SchemaContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SchemaContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SchemaContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SchemaContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SchemaContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, service_name, api_id, schema_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + schema_id, # type: str + parameters, # type: "models.SchemaContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.SchemaContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.SchemaContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'SchemaContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('SchemaContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('SchemaContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - - def create_or_update( - self, resource_group_name, service_name, api_id, schema_id, parameters, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + schema_id, # type: str + parameters, # type: "models.SchemaContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.SchemaContract"] """Creates or updates schema configuration for the API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in - the current API Management service instance. + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. :type schema_id: str :param parameters: The schema contents to apply. :type parameters: ~azure.mgmt.apimanagement.models.SchemaContract - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns SchemaContract or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.SchemaContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.SchemaContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either SchemaContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.SchemaContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - api_id=api_id, - schema_id=schema_id, - parameters=parameters, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.SchemaContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - header_dict = { - 'ETag': 'str', - } - deserialized = self._deserialize('SchemaContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + api_id=api_id, + schema_id=schema_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SchemaContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, schema_id, if_match, force=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + schema_id, # type: str + if_match, # type: str + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the schema configuration at the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param schema_id: Schema identifier within an API. Must be unique in - the current API Management service instance. + :param schema_id: Schema identifier within an API. Must be unique in the current API Management + service instance. :type schema_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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. :type force: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'schemaId': self._serialize.url("schema_id", schema_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if force is not None: query_parameters['force'] = self._serialize.query("force", force, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}'} + 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 ee1c4ece98cd..70657e5ae431 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,433 +1,452 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiTagDescriptionOperations(object): """ApiTagDescriptionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagDescriptionCollection"] + """Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is + defined on API level but tag may be assigned to the Operations. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param 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 |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagDescriptionContract - :rtype: - ~azure.mgmt.apimanagement.models.TagDescriptionContractPaged[~azure.mgmt.apimanagement.models.TagDescriptionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagDescriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDescriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagDescriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagDescriptionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions'} + 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 def get_entity_tag( - self, resource_group_name, service_name, api_id, tag_description_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_description_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_description_id: Tag description identifier. Used when - creating tagDescription for API/Tag association. Based on API and Tag - names. + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. :type tag_description_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore def get( - self, resource_group_name, service_name, api_id, tag_description_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_description_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagDescriptionContract" """Get Tag description in scope of API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_description_id: Tag description identifier. Used when - creating tagDescription for API/Tag association. Based on API and Tag - names. + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. :type tag_description_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDescriptionContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDescriptionContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDescriptionContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagDescriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, api_id, tag_description_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_description_id, # type: str + parameters, # type: "models.TagDescriptionCreateParameters" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.TagDescriptionContract" """Create/Update tag description in scope of the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_description_id: Tag description identifier. Used when - creating tagDescription for API/Tag association. Based on API and Tag - names. + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. :type tag_description_id: str :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagDescriptionContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagDescriptionContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagDescriptionContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagDescriptionContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'TagDescriptionCreateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TagDescriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagDescriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagDescriptionContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} # type: ignore def delete( - self, resource_group_name, service_name, api_id, tag_description_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_description_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Delete tag description for the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_description_id: Tag description identifier. Used when - creating tagDescription for API/Tag association. Based on API and Tag - names. + :param tag_description_id: Tag description identifier. Used when creating tagDescription for + API/Tag association. Based on API and Tag names. :type tag_description_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagDescriptionId': self._serialize.url("tag_description_id", tag_description_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}'} + 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 58db85d6f681..ead263ab555f 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,469 +1,504 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ApiVersionSetOperations(object): """ApiVersionSetOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of API Version Sets in the specified service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiVersionSetCollection"] + """Lists a collection of API Version Sets 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiVersionSetContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiVersionSetContractPaged[~azure.mgmt.apimanagement.models.ApiVersionSetContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiVersionSetCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiVersionSetCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiVersionSetCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiVersionSetContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, version_set_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Api Version Set specified - by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + version_set_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Api Version Set specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param version_set_id: Api Version Set identifier. Must be unique in - the current API Management service instance. + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. :type version_set_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore def get( - self, resource_group_name, service_name, version_set_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + version_set_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiVersionSetContract" """Gets the details of the Api Version Set 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 version_set_id: Api Version Set identifier. Must be unique in - the current API Management service instance. + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. :type version_set_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiVersionSetContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiVersionSetContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiVersionSetContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ApiVersionSetContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, version_set_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + version_set_id, # type: str + parameters, # type: "models.ApiVersionSetContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ApiVersionSetContract" """Creates or Updates a Api Version Set. :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 version_set_id: Api Version Set identifier. Must be unique in - the current API Management service instance. + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. :type version_set_id: str :param parameters: Create or update parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiVersionSetContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiVersionSetContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiVersionSetContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiVersionSetContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ApiVersionSetContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ApiVersionSetContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiVersionSetContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore def update( - self, resource_group_name, service_name, version_set_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + version_set_id, # type: str + if_match, # type: str + parameters, # type: "models.ApiVersionSetUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.ApiVersionSetContract" """Updates the details of the Api VersionSet 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 version_set_id: Api Version Set identifier. Must be unique in - the current API Management service instance. + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. :type version_set_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.ApiVersionSetUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ApiVersionSetUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ApiVersionSetContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore def delete( - self, resource_group_name, service_name, version_set_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + version_set_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific Api Version Set. :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 version_set_id: Api Version Set identifier. Must be unique in - the current API Management service instance. + :param version_set_id: Api Version Set identifier. Must be unique in the current API Management + service instance. :type version_set_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'versionSetId': self._serialize.url("version_set_id", version_set_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_authorization_server_operations.py index 9ec7b59cd053..80e73c75755e 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,136 +1,154 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class AuthorizationServerOperations(object): """AuthorizationServerOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of authorization servers defined within a service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.AuthorizationServerCollection"] + """Lists a collection of authorization servers 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 |
+ :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 + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of AuthorizationServerContract - :rtype: - ~azure.mgmt.apimanagement.models.AuthorizationServerContractPaged[~azure.mgmt.apimanagement.models.AuthorizationServerContract] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AuthorizationServerCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.AuthorizationServerCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AuthorizationServerCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('AuthorizationServerCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.AuthorizationServerContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, authsid, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the authorizationServer - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the authorizationServer specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -138,58 +156,64 @@ def get_entity_tag( :type service_name: str :param authsid: Identifier of the authorization server. :type authsid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore def get( - self, resource_group_name, service_name, authsid, custom_headers=None, raw=False, **operation_config): - """Gets the details of the authorization server specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AuthorizationServerContract" + """Gets the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -197,68 +221,67 @@ def get( :type service_name: str :param authsid: Identifier of the authorization server. :type authsid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AuthorizationServerContract or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationServerContract, or the result of cls(response) :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('AuthorizationServerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, authsid, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates new authorization server or updates an existing authorization - server. + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + parameters, # type: "models.AuthorizationServerContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.AuthorizationServerContract" + """Creates new authorization server or updates an existing authorization server. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -267,84 +290,83 @@ def create_or_update( :param authsid: Identifier of the authorization server. :type authsid: str :param parameters: Create or update parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AuthorizationServerContract or ClientRawResponse if raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationServerContract, or the result of cls(response) :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'AuthorizationServerContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('AuthorizationServerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('AuthorizationServerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore def update( - self, resource_group_name, service_name, authsid, parameters, if_match, custom_headers=None, raw=False, **operation_config): - """Updates the details of the authorization server specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + if_match, # type: str + parameters, # type: "models.AuthorizationServerUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.AuthorizationServerContract" + """Updates the details of the authorization server specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -352,65 +374,76 @@ def update( :type service_name: str :param authsid: Identifier of the authorization server. :type authsid: str - :param parameters: OAuth2 Server settings Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.AuthorizationServerUpdateContract - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: OAuth2 Server settings Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'AuthorizationServerUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore def delete( - self, resource_group_name, service_name, authsid, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific authorization server instance. :param resource_group_name: The name of the resource group. @@ -419,58 +452,63 @@ def delete( :type service_name: str :param authsid: Identifier of the authorization server. :type authsid: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}'} # type: ignore def list_secrets( - self, resource_group_name, service_name, authsid, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + authsid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AuthorizationServerSecretsContract" """Gets the client secret details of the authorization server. :param resource_group_name: The name of the resource group. @@ -479,55 +517,52 @@ def list_secrets( :type service_name: str :param authsid: Identifier of the authorization server. :type authsid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ClientSecretContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthorizationServerSecretsContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AuthorizationServerSecretsContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.AuthorizationServerSecretsContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'authsid': self._serialize.url("authsid", authsid, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ClientSecretContract', response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AuthorizationServerSecretsContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets'} + 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 e871231af783..d3d968d1ce61 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,544 +1,585 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class BackendOperations(object): """BackendOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.BackendCollection"] """Lists a collection of backends 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| title | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| url | filter | - ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| url | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of BackendContract - :rtype: - ~azure.mgmt.apimanagement.models.BackendContractPaged[~azure.mgmt.apimanagement.models.BackendContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.BackendCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BackendCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('BackendCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.BackendContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, backend_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the backend specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the backend 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 backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore def get( - self, resource_group_name, service_name, backend_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.BackendContract" """Gets the details of the backend 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 backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: BackendContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.BackendContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BackendContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BackendContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('BackendContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, backend_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + parameters, # type: "models.BackendContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.BackendContract" """Creates or Updates a backend. :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 backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: BackendContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.BackendContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BackendContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.BackendContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.BackendContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'BackendContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('BackendContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('BackendContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore def update( - self, resource_group_name, service_name, backend_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + if_match, # type: str + parameters, # type: "models.BackendUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.BackendContract" """Updates an existing backend. :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 backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.BackendUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'BackendUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('BackendContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore def delete( - self, resource_group_name, service_name, backend_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified backend. :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 backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}'} # type: ignore def reconnect( - self, resource_group_name, service_name, backend_id, after=None, custom_headers=None, raw=False, **operation_config): - """Notifies the APIM proxy to create a new connection to the backend after - the specified timeout. If no timeout was specified, timeout of 2 - minutes is used. + self, + resource_group_name, # type: str + service_name, # type: str + backend_id, # type: str + after=None, # type: Optional[datetime.timedelta] + **kwargs # type: Any + ): + # type: (...) -> None + """Notifies the APIM proxy to create a new connection to the backend after the specified timeout. + If no timeout was specified, timeout of 2 minutes is used. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param backend_id: Identifier of the Backend entity. Must be unique in - the current API Management service instance. + :param backend_id: Identifier of the Backend entity. Must be unique in the current API + Management service instance. :type backend_id: str - :param after: Duration in ISO8601 format after which reconnect will be - initiated. Minimum duration of the Reconnect is PT2M. - :type after: timedelta - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param after: Duration in ISO8601 format after which reconnect will be initiated. Minimum + duration of the Reconnect is PT2M. + :type after: ~datetime.timedelta + :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 """ - parameters = None - if after is not None: - parameters = models.BackendReconnectContract(after=after) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.BackendReconnectContract(after=after) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.reconnect.metadata['url'] + url = self.reconnect.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'backendId': self._serialize.url("backend_id", backend_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - if parameters is not None: - body_content = self._serialize.body(parameters, 'BackendReconnectContract') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'BackendReconnectContract') else: body_content = None - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - reconnect.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect'} + 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 3f0926176117..b9bd60fb6ecd 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,47 +1,60 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class CacheOperations(object): """CacheOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of all external Caches in the specified service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CacheCollection"] + """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 @@ -51,413 +64,435 @@ def list_by_service( :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of CacheContract - :rtype: - ~azure.mgmt.apimanagement.models.CacheContractPaged[~azure.mgmt.apimanagement.models.CacheContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.CacheCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CacheCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('CacheCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.CacheContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, cache_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Cache specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + cache_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier - (should be either 'default' or valid Azure region identifier). + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). :type cache_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore def get( - self, resource_group_name, service_name, cache_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + cache_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CacheContract" """Gets the details of the Cache 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 cache_id: Identifier of the Cache entity. Cache identifier - (should be either 'default' or valid Azure region identifier). + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). :type cache_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CacheContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.CacheContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CacheContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CacheContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CacheContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, cache_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates an External Cache to be used in Api Management - instance. + self, + resource_group_name, # type: str + service_name, # type: str + cache_id, # type: str + parameters, # type: "models.CacheContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.CacheContract" + """Creates or updates an External Cache to be used in Api Management 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 cache_id: Identifier of the Cache entity. Cache identifier - (should be either 'default' or valid Azure region identifier). + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). :type cache_id: str :param parameters: Create or Update parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CacheContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.CacheContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CacheContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CacheContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CacheContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'CacheContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('CacheContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('CacheContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore def update( - self, resource_group_name, service_name, cache_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + cache_id, # type: str + if_match, # type: str + parameters, # type: "models.CacheUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.CacheContract" """Updates the details of the cache 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 cache_id: Identifier of the Cache entity. Cache identifier - (should be either 'default' or valid Azure region identifier). + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). :type cache_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.CacheUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'CacheUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CacheContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} # type: ignore def delete( - self, resource_group_name, service_name, cache_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + cache_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific Cache. :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 cache_id: Identifier of the Cache entity. Cache identifier - (should be either 'default' or valid Azure region identifier). + :param cache_id: Identifier of the Cache entity. Cache identifier (should be either 'default' + or valid Azure region identifier). :type cache_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'cacheId': self._serialize.url("cache_id", cache_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}'} + 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 ab5870bb7998..db3faa9543e7 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,412 +1,428 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class CertificateOperations(object): """CertificateOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of all certificates in the specified service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.CertificateCollection"] + """Lists a collection of all certificates 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| subject | filter | ge, le, eq, ne, gt, - lt | substringof, contains, startswith, endswith |
| thumbprint | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| expirationDate | filter | ge, le, eq, ne, gt, lt | - |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| expirationDate | filter | ge, le, eq, ne, gt, lt | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of CertificateContract - :rtype: - ~azure.mgmt.apimanagement.models.CertificateContractPaged[~azure.mgmt.apimanagement.models.CertificateContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.CertificateCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CertificateCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('CertificateCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.CertificateContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, certificate_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the certificate specified by - its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + certificate_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the certificate 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 certificate_id: Identifier of the certificate entity. Must be - unique in the current API Management service instance. + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. :type certificate_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore def get( - self, resource_group_name, service_name, certificate_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + certificate_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.CertificateContract" """Gets the details of the certificate 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 certificate_id: Identifier of the certificate entity. Must be - unique in the current API Management service instance. + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. :type certificate_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CertificateContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.CertificateContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.CertificateContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('CertificateContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, certificate_id, data, password, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates the certificate being used for authentication with - the backend. + self, + resource_group_name, # type: str + service_name, # type: str + certificate_id, # type: str + parameters, # type: "models.CertificateCreateOrUpdateParameters" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.CertificateContract" + """Creates or updates the certificate being used for authentication with the backend. :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 certificate_id: Identifier of the certificate entity. Must be - unique in the current API Management service instance. + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. :type certificate_id: str - :param data: Base 64 encoded certificate using the - application/x-pkcs12 representation. - :type data: str - :param password: Password for the Certificate - :type password: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param parameters: Create or Update parameters. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: CertificateContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.CertificateContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CertificateContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.CertificateContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.CertificateCreateOrUpdateParameters(data=data, password=password) + cls = kwargs.pop('cls', None) # type: ClsType["models.CertificateContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'CertificateCreateOrUpdateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('CertificateContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('CertificateContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CertificateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore def delete( - self, resource_group_name, service_name, certificate_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + certificate_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific certificate. :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 certificate_id: Identifier of the certificate entity. Must be - unique in the current API Management service instance. + :param certificate_id: Identifier of the certificate entity. Must be unique in the current API + Management service instance. :type certificate_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'certificateId': self._serialize.url("certificate_id", certificate_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_content_item_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_content_item_operations.py new file mode 100644 index 000000000000..36aa1222b5aa --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_content_item_operations.py @@ -0,0 +1,416 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ContentTypeContentItemOperations(object): + """ContentTypeContentItemOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ContentItemCollection"] + """Returns list of content items. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ContentItemCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentItemCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentItemCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ContentItemCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems'} # type: ignore + + def get_entity_tag( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + content_item_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Returns content item metadata. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :type content_item_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: bool, or the result of cls(response) + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_entity_tag.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.head(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + 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 + + def get( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + content_item_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ContentItemContract" + """Returns content item details. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + content_item_id, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ContentItemContract" + """Creates new content item. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentItemContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + content_item_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Removes specified content item. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param content_item_id: Content item identifier. + :type content_item_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'contentItemId': self._serialize.url("content_item_id", content_item_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py new file mode 100644 index 000000000000..2ee1ebe1fc30 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_content_type_operations.py @@ -0,0 +1,331 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ContentTypeOperations(object): + """ContentTypeOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_service( + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ContentTypeCollection"] + """Returns list of content types. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param service_name: The name of the API Management service. + :type service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ContentTypeCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.ContentTypeCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentTypeCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_service.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ContentTypeCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes'} # type: ignore + + def get( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ContentTypeContract" + """Gets API Management content type details. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContentTypeContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ContentTypeContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ContentTypeContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ContentTypeContract" + """Creates or updates an Content Type. + + :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 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. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContentTypeContract, or the result of cls(response) + :rtype: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.put(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if response.status_code == 201: + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ContentTypeContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + service_name, # type: str + content_type_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Removes specified content type. + + :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 content_type_id: Content type identifier. + :type content_type_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'contentTypeId': self._serialize.url("content_type_id", content_type_id, 'str', max_length=80, min_length=1), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_delegation_settings_operations.py index 41ae87b61261..cd6fc55252c2 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,229 +1,251 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DelegationSettingsOperations(object): """DelegationSettingsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def get_entity_tag( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state (Etag) version of the DelegationSettings. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PortalDelegationSettings" """Get Delegation Settings for the Portal. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalDelegationSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalDelegationSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalDelegationSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalDelegationSettings', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore def update( - self, resource_group_name, service_name, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + if_match, # type: str + parameters, # type: "models.PortalDelegationSettings" + **kwargs # type: Any + ): + # type: (...) -> None """Update Delegation 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 parameters: Update Delegation settings. - :type parameters: - ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update Delegation settings. + :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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore def create_or_update( - self, resource_group_name, service_name, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + parameters, # type: "models.PortalDelegationSettings" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.PortalDelegationSettings" """Create or Update Delegation settings. :param resource_group_name: The name of the resource group. @@ -231,127 +253,120 @@ 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: - ~azure.mgmt.apimanagement.models.PortalDelegationSettings - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalDelegationSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalDelegationSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalDelegationSettings + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalDelegationSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'PortalDelegationSettings') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalDelegationSettings', response) + deserialized = self._deserialize('PortalDelegationSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation'} # type: ignore def list_secrets( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PortalSettingValidationKeyContract" """Gets the secret validation key of the DelegationSettings. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalSettingValidationKeyContract or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSettingValidationKeyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSettingValidationKeyContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSettingValidationKeyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalSettingValidationKeyContract', response) + deserialized = self._deserialize('PortalSettingValidationKeyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets'} + 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 new file mode 100644 index 000000000000..c7c734d04873 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_deleted_services_operations.py @@ -0,0 +1,236 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_by_subscription( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DeletedServicesCollection"] + """Lists all soft-deleted services available for undelete for the given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedServicesCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.DeletedServicesCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DeletedServicesCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('DeletedServicesCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices'} # type: ignore + + def get_by_name( + self, + service_name, # type: str + location, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DeletedServiceContract" + """Get soft-deleted Api Management Service by name. + + :param service_name: The name of the API Management service. + :type service_name: str + :param location: The location of the deleted API Management service. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_by_name.metadata['url'] # type: ignore + path_format_arguments = { + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}'} # type: ignore + + def purge( + self, + service_name, # type: str + location, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional["models.DeletedServiceContract"] + """Purges Api Management Service (deletes it with no option to undelete). + + :param service_name: The name of the API Management service. + :type service_name: str + :param location: The location of the deleted API Management service. + :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: ~azure.mgmt.apimanagement.models.DeletedServiceContract or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.DeletedServiceContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + + # Construct URL + url = self.purge.metadata['url'] # type: ignore + path_format_arguments = { + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 202: + deserialized = self._deserialize('DeletedServiceContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + 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 e9d29894949a..636a844fc77c 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,468 +1,505 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class DiagnosticOperations(object): """DiagnosticOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.DiagnosticCollection"] """Lists all diagnostics of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of DiagnosticContract - :rtype: - ~azure.mgmt.apimanagement.models.DiagnosticContractPaged[~azure.mgmt.apimanagement.models.DiagnosticContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.DiagnosticCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('DiagnosticCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.DiagnosticContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, diagnostic_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Diagnostic specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + diagnostic_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore def get( - self, resource_group_name, service_name, diagnostic_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + diagnostic_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.DiagnosticContract" """Gets the details of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DiagnosticContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, diagnostic_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + diagnostic_id, # type: str + parameters, # type: "models.DiagnosticContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.DiagnosticContract" """Creates a new Diagnostic or updates an existing one. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: DiagnosticContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'DiagnosticContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('DiagnosticContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore def update( - self, resource_group_name, service_name, diagnostic_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + diagnostic_id, # type: str + if_match, # type: str + parameters, # type: "models.DiagnosticContract" + **kwargs # type: Any + ): + # type: (...) -> "models.DiagnosticContract" """Updates the details of the Diagnostic 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 diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str :param parameters: Diagnostic Update parameters. :type parameters: ~azure.mgmt.apimanagement.models.DiagnosticContract - :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.DiagnosticContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.DiagnosticContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'DiagnosticContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('DiagnosticContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} # type: ignore def delete( - self, resource_group_name, service_name, diagnostic_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + diagnostic_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified Diagnostic. :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 diagnostic_id: Diagnostic identifier. Must be unique in the - current API Management service instance. + :param diagnostic_id: Diagnostic identifier. Must be unique in the current API Management + service instance. :type diagnostic_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'diagnosticId': self._serialize.url("diagnostic_id", diagnostic_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}'} + 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 aee6bc1b4943..ac8ee4c22761 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,518 +1,497 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class EmailTemplateOperations(object): """EmailTemplateOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of properties defined within a service instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.EmailTemplateCollection"] + """Gets all email templates. :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 |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of EmailTemplateContract - :rtype: - ~azure.mgmt.apimanagement.models.EmailTemplateContractPaged[~azure.mgmt.apimanagement.models.EmailTemplateContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.EmailTemplateCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EmailTemplateCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('EmailTemplateCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.EmailTemplateContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, template_name, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the email template specified by - its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + template_name, # type: Union[str, "models.TemplateName"] + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the email template specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param template_name: Email Template Name Identifier. Possible values - include: 'applicationApprovedNotificationMessage', - 'accountClosedDeveloper', - 'quotaLimitApproachingDeveloperNotificationMessage', - 'newDeveloperNotificationMessage', 'emailChangeIdentityDefault', - 'inviteUserNotificationMessage', 'newCommentNotificationMessage', - 'confirmSignUpIdentityDefault', 'newIssueNotificationMessage', - 'purchaseDeveloperNotificationMessage', - 'passwordResetIdentityDefault', - 'passwordResetByAdminNotificationMessage', - 'rejectDeveloperNotificationMessage', - 'requestDeveloperNotificationMessage' - :type template_name: str or - ~azure.mgmt.apimanagement.models.TemplateName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param template_name: Email Template Name Identifier. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'templateName': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore def get( - self, resource_group_name, service_name, template_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + template_name, # type: Union[str, "models.TemplateName"] + **kwargs # type: Any + ): + # type: (...) -> "models.EmailTemplateContract" """Gets the details of the email template 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 template_name: Email Template Name Identifier. Possible values - include: 'applicationApprovedNotificationMessage', - 'accountClosedDeveloper', - 'quotaLimitApproachingDeveloperNotificationMessage', - 'newDeveloperNotificationMessage', 'emailChangeIdentityDefault', - 'inviteUserNotificationMessage', 'newCommentNotificationMessage', - 'confirmSignUpIdentityDefault', 'newIssueNotificationMessage', - 'purchaseDeveloperNotificationMessage', - 'passwordResetIdentityDefault', - 'passwordResetByAdminNotificationMessage', - 'rejectDeveloperNotificationMessage', - 'requestDeveloperNotificationMessage' - :type template_name: str or - ~azure.mgmt.apimanagement.models.TemplateName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: EmailTemplateContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param template_name: Email Template Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'templateName': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('EmailTemplateContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, template_name, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + template_name, # type: Union[str, "models.TemplateName"] + parameters, # type: "models.EmailTemplateUpdateParameters" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.EmailTemplateContract" """Updates an Email Template. :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 template_name: Email Template Name Identifier. Possible values - include: 'applicationApprovedNotificationMessage', - 'accountClosedDeveloper', - 'quotaLimitApproachingDeveloperNotificationMessage', - 'newDeveloperNotificationMessage', 'emailChangeIdentityDefault', - 'inviteUserNotificationMessage', 'newCommentNotificationMessage', - 'confirmSignUpIdentityDefault', 'newIssueNotificationMessage', - 'purchaseDeveloperNotificationMessage', - 'passwordResetIdentityDefault', - 'passwordResetByAdminNotificationMessage', - 'rejectDeveloperNotificationMessage', - 'requestDeveloperNotificationMessage' - :type template_name: str or - ~azure.mgmt.apimanagement.models.TemplateName + :param template_name: Email Template Name Identifier. + :type template_name: str or ~azure.mgmt.apimanagement.models.TemplateName :param parameters: Email Template update parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: EmailTemplateContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EmailTemplateContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.EmailTemplateContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EmailTemplateContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'templateName': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('EmailTemplateContract', response) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('EmailTemplateContract', response) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore def update( - self, resource_group_name, service_name, template_name, parameters, if_match, custom_headers=None, raw=False, **operation_config): - """Updates the specific Email Template. + self, + resource_group_name, # type: str + service_name, # type: str + template_name, # type: Union[str, "models.TemplateName"] + if_match, # type: str + parameters, # type: "models.EmailTemplateUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.EmailTemplateContract" + """Updates API Management email template. :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 template_name: Email Template Name Identifier. Possible values - include: 'applicationApprovedNotificationMessage', - 'accountClosedDeveloper', - 'quotaLimitApproachingDeveloperNotificationMessage', - 'newDeveloperNotificationMessage', 'emailChangeIdentityDefault', - 'inviteUserNotificationMessage', 'newCommentNotificationMessage', - 'confirmSignUpIdentityDefault', 'newIssueNotificationMessage', - 'purchaseDeveloperNotificationMessage', - 'passwordResetIdentityDefault', - 'passwordResetByAdminNotificationMessage', - 'rejectDeveloperNotificationMessage', - 'requestDeveloperNotificationMessage' - :type template_name: str or - ~azure.mgmt.apimanagement.models.TemplateName - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.EmailTemplateUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param template_name: Email Template Name Identifier. + :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'templateName': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'EmailTemplateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('EmailTemplateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} # type: ignore def delete( - self, resource_group_name, service_name, template_name, if_match, custom_headers=None, raw=False, **operation_config): - """Reset the Email Template to default template provided by the API - Management service instance. + self, + resource_group_name, # type: str + service_name, # type: str + template_name, # type: Union[str, "models.TemplateName"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Reset the Email Template to default template provided by 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 template_name: Email Template Name Identifier. Possible values - include: 'applicationApprovedNotificationMessage', - 'accountClosedDeveloper', - 'quotaLimitApproachingDeveloperNotificationMessage', - 'newDeveloperNotificationMessage', 'emailChangeIdentityDefault', - 'inviteUserNotificationMessage', 'newCommentNotificationMessage', - 'confirmSignUpIdentityDefault', 'newIssueNotificationMessage', - 'purchaseDeveloperNotificationMessage', - 'passwordResetIdentityDefault', - 'passwordResetByAdminNotificationMessage', - 'rejectDeveloperNotificationMessage', - 'requestDeveloperNotificationMessage' - :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. + :param template_name: Email Template Name Identifier. + :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'templateName': self._serialize.url("template_name", template_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}'} + 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 a26b4fe76387..ab61e90d1801 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,331 +1,363 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class GatewayApiOperations(object): """GatewayApiOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, gateway_id, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiCollection"] """Lists a collection of the APIs associated with a gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiContractPaged[~azure.mgmt.apimanagement.models.ApiContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis'} + 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 def get_entity_tag( - self, resource_group_name, service_name, gateway_id, api_id, custom_headers=None, raw=False, **operation_config): - """Checks that API entity specified by identifier is associated with the - Gateway entity. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks that API entity specified by identifier is associated with the Gateway entity. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} + 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 def create_or_update( - self, resource_group_name, service_name, gateway_id, api_id, provisioning_state=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiContract" """Adds an API to the specified Gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param provisioning_state: Provisioning state. Possible values - include: 'created' - :type provisioning_state: str or - ~azure.mgmt.apimanagement.models.ProvisioningState - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = None - if provisioning_state is not None: - parameters = models.AssociationContract(provisioning_state=provisioning_state) + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.AssociationContract() + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - if parameters is not None: - body_content = self._serialize.body(parameters, 'AssociationContract') + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + if _parameters is not None: + body_content = self._serialize.body(_parameters, 'AssociationContract') else: body_content = None - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiContract', response) + deserialized = self._deserialize('ApiContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiContract', response) + deserialized = self._deserialize('ApiContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} # type: ignore def delete( - self, resource_group_name, service_name, gateway_id, api_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified API from the specified Gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param api_id: API identifier. Must be unique in the current API - Management service instance. + :param api_id: API identifier. Must be unique in the current API Management service instance. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}'} + 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_hostname_configuration_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_gateway_hostname_configuration_operations.py index 8f7ac6aecb3f..9056d5a0321e 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,412 +1,452 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class GatewayHostnameConfigurationOperations(object): """GatewayHostnameConfigurationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, gateway_id, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists the collection of hostname configurations for the specified - gateway. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.GatewayHostnameConfigurationCollection"] + """Lists the collection of hostname configurations for the specified gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. + :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of - GatewayHostnameConfigurationContract - :rtype: - ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContractPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GatewayHostnameConfigurationCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayHostnameConfigurationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('GatewayHostnameConfigurationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GatewayHostnameConfigurationContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations'} + 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 def get_entity_tag( - self, resource_group_name, service_name, gateway_id, hc_id, custom_headers=None, raw=False, **operation_config): - """Checks that hostname configuration entity specified by identifier - exists for specified Gateway entity. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + hc_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks that hostname configuration entity specified by identifier exists for specified Gateway + entity. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param hc_id: Gateway hostname configuration identifier. Must be - unique in the scope of parent Gateway entity. + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. :type hc_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore def get( - self, resource_group_name, service_name, gateway_id, hc_id, custom_headers=None, raw=False, **operation_config): - """Gets the details of the Gateway hostname configuration specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + hc_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayHostnameConfigurationContract" + """Get details of a hostname 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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param hc_id: Gateway hostname configuration identifier. Must be - unique in the scope of parent Gateway entity. + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. :type hc_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayHostnameConfigurationContract or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayHostnameConfigurationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayHostnameConfigurationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GatewayHostnameConfigurationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, gateway_id, hc_id, parameters, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + hc_id, # type: str + parameters, # type: "models.GatewayHostnameConfigurationContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayHostnameConfigurationContract" """Creates of updates hostname configuration for a Gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param hc_id: Gateway hostname configuration identifier. Must be - unique in the scope of parent Gateway entity. + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. :type hc_id: str :param parameters: - :type parameters: - ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayHostnameConfigurationContract or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.apimanagement.models.GatewayHostnameConfigurationContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + header_parameters = {} # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'GatewayHostnameConfigurationContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('GatewayHostnameConfigurationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GatewayHostnameConfigurationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayHostnameConfigurationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} # type: ignore def delete( - self, resource_group_name, service_name, gateway_id, hc_id, custom_headers=None, raw=False, **operation_config): - """Deletes the specified hostname configuration from the specified - Gateway. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + hc_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes the specified hostname configuration from the specified Gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param hc_id: Gateway hostname configuration identifier. Must be - unique in the scope of parent Gateway entity. + :param hc_id: Gateway hostname configuration identifier. Must be unique in the scope of parent + Gateway entity. :type hc_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param if_match: ETag of the Entity. ETag should match the current entity state from the header + response of the GET request or it should be * for unconditional update. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), 'hcId': self._serialize.url("hc_id", hc_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}'} + 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 40f29ec66b83..bb14a2d1ab80 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,682 +1,738 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class GatewayOperations(object): """GatewayOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.GatewayCollection"] """Lists a collection of gateways registered with service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str + :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. + :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GatewayContract - :rtype: - ~azure.mgmt.apimanagement.models.GatewayContractPaged[~azure.mgmt.apimanagement.models.GatewayContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.GatewayCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('GatewayCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GatewayContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, gateway_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Gateway specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Gateway 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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore def get( - self, resource_group_name, service_name, gateway_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayContract" """Gets the details of the Gateway 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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GatewayContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, gateway_id, if_match=None, location_data=None, description=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + if_match=None, # type: Optional[str] + location_data=None, # type: Optional["models.ResourceLocationDataContract"] + description=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayContract" """Creates or updates a Gateway to be used in Api Management 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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str :param location_data: Gateway location. - :type location_data: - ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. :type description: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GatewayContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.GatewayContract(location_data=location_data, description=description) + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayContract(location_data=location_data, description=description) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body - body_content = self._serialize.body(parameters, 'GatewayContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('GatewayContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GatewayContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore def update( - self, resource_group_name, service_name, gateway_id, if_match, location_data=None, description=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + if_match, # type: str + location_data=None, # type: Optional["models.ResourceLocationDataContract"] + description=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayContract" """Updates the details of the gateway 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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 location_data: Gateway location. - :type location_data: - ~azure.mgmt.apimanagement.models.ResourceLocationDataContract - :param description: Gateway description + :type location_data: ~azure.mgmt.apimanagement.models.ResourceLocationDataContract + :param description: Gateway description. :type description: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.GatewayContract(location_data=location_data, description=description) + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayContract(location_data=location_data, description=description) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body - body_content = self._serialize.body(parameters, 'GatewayContract') + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore def delete( - self, resource_group_name, service_name, gateway_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific Gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}'} # type: ignore def list_keys( - self, resource_group_name, service_name, gateway_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayKeysContract" """Retrieves gateway keys. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayKeysContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayKeysContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayKeysContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayKeysContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_keys.metadata['url'] + url = self.list_keys.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GatewayKeysContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GatewayKeysContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} + list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys'} # type: ignore def regenerate_key( - self, resource_group_name, service_name, gateway_id, key_type, custom_headers=None, raw=False, **operation_config): - """Regenerates specified gateway key invalidating any tokens created with - it. + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + key_type, # type: Union[str, "models.KeyType"] + **kwargs # type: Any + ): + # type: (...) -> None + """Regenerates specified gateway key invalidating any tokens created with it. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str - :param key_type: The Key being regenerated. Possible values include: - 'primary', 'secondary' + :param key_type: The Key being regenerated. :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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 """ - parameters = models.GatewayKeyRegenerationRequestContract(key_type=key_type) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayKeyRegenerationRequestContract(key_type=key_type) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.regenerate_key.metadata['url'] + url = self.regenerate_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GatewayKeyRegenerationRequestContract') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayKeyRegenerationRequestContract') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey'} + 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 def generate_token( - self, resource_group_name, service_name, gateway_id, expiry, key_type="primary", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + gateway_id, # type: str + key_type, # type: Union[str, "models.KeyType"] + expiry, # type: datetime.datetime + **kwargs # type: Any + ): + # type: (...) -> "models.GatewayTokenContract" """Gets the Shared Access Authorization Token for the gateway. :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 gateway_id: Gateway entity identifier. Must be unique in the - current API Management service instance. Must not have value 'managed' + :param gateway_id: Gateway entity identifier. Must be unique in the current API Management + service instance. Must not have value 'managed'. :type gateway_id: str :param key_type: The Key to be used to generate gateway token. - Possible values include: 'primary', 'secondary' :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: The Expiry time of the Token. Maximum token expiry time - is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GatewayTokenContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GatewayTokenContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GatewayTokenContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.GatewayTokenRequestContract(key_type=key_type, expiry=expiry) + cls = kwargs.pop('cls', None) # type: ClsType["models.GatewayTokenContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.GatewayTokenRequestContract(key_type=key_type, expiry=expiry) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.generate_token.metadata['url'] + url = self.generate_token.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'GatewayTokenRequestContract') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'GatewayTokenRequestContract') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GatewayTokenContract', response) + deserialized = self._deserialize('GatewayTokenContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - generate_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken'} + 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/_group_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_group_operations.py index e8c8e9496ed4..8cfa87f5cbc2 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,473 +1,508 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class GroupOperations(object): """GroupOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.GroupCollection"] """Lists a collection of groups 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 |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| aadObjectId | filter | eq | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| externalId | filter | eq | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GroupContract - :rtype: - ~azure.mgmt.apimanagement.models.GroupContractPaged[~azure.mgmt.apimanagement.models.GroupContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.GroupCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GroupContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, group_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the group specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the group 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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore def get( - self, resource_group_name, service_name, group_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GroupContract" """Gets the details of the group 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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GroupContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GroupContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GroupContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, group_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + parameters, # type: "models.GroupCreateParameters" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.GroupContract" """Creates or Updates a group. :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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GroupContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GroupContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'GroupCreateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('GroupContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GroupContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore def update( - self, resource_group_name, service_name, group_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + if_match, # type: str + parameters, # type: "models.GroupUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.GroupContract" """Updates the details of the group 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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.GroupUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'GroupUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('GroupContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} # type: ignore def delete( - self, resource_group_name, service_name, group_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific group of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}'} + 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 abfb01cb5772..87dd53dadd78 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,330 +1,355 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class GroupUserOperations(object): """GroupUserOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, group_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.UserCollection"] """Lists a collection of user entities associated with the group. :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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| firstName | filter | ge, le, eq, ne, gt, - lt | substringof, contains, startswith, endswith |
| lastName | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| email | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| registrationDate - | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, - le, eq, ne, gt, lt | substringof, contains, startswith, endswith | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, + le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of UserContract - :rtype: - ~azure.mgmt.apimanagement.models.UserContractPaged[~azure.mgmt.apimanagement.models.UserContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.UserCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('UserCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.UserContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users'} # type: ignore def check_entity_exists( - self, resource_group_name, service_name, group_id, user_id, custom_headers=None, raw=False, **operation_config): - """Checks that user entity specified by identifier is associated with the - group entity. + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks that user entity specified by identifier is associated with the group entity. :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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.check_entity_exists.metadata['url'] + url = self.check_entity_exists.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore def create( - self, resource_group_name, service_name, group_id, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.UserContract" """Add existing user to existing group. :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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: UserContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.UserContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create.metadata['url'] + url = self.create.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('UserContract', response) + deserialized = self._deserialize('UserContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('UserContract', response) + deserialized = self._deserialize('UserContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} # type: ignore def delete( - self, resource_group_name, service_name, group_id, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + group_id, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Remove existing user from existing group. :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 group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}'} + 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 458ed98212a1..9b1415f10ba8 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,251 +1,268 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class IdentityProviderOperations(object): """IdentityProviderOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): - """Lists a collection of Identity Provider configured in the specified - service instance. + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of IdentityProviderContract - :rtype: - ~azure.mgmt.apimanagement.models.IdentityProviderContractPaged[~azure.mgmt.apimanagement.models.IdentityProviderContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.IdentityProviderList] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IdentityProviderList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('IdentityProviderList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.IdentityProviderContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, identity_provider_name, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the identityProvider specified - by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the identityProvider 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 identity_provider_name: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_name: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore def get( - self, resource_group_name, service_name, identity_provider_name, custom_headers=None, raw=False, **operation_config): - """Gets the configuration details of the identity Provider configured in - specified service instance. + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + **kwargs # type: Any + ): + # type: (...) -> "models.IdentityProviderContract" + """Gets the configuration details of the identity Provider configured in specified service + instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_name: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IdentityProviderContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('IdentityProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, identity_provider_name, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + parameters, # type: "models.IdentityProviderCreateContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.IdentityProviderContract" """Creates or Updates the IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -253,87 +270,84 @@ 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. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_name: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType + :type identity_provider_name: str or ~azure.mgmt.apimanagement.models.IdentityProviderType :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IdentityProviderContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IdentityProviderContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IdentityProviderContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IdentityProviderContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IdentityProviderCreateContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('IdentityProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('IdentityProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore def update( - self, resource_group_name, service_name, identity_provider_name, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + if_match, # type: str + parameters, # type: "models.IdentityProviderUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.IdentityProviderContract" """Updates an existing IdentityProvider configuration. :param resource_group_name: The name of the resource group. @@ -341,69 +355,77 @@ def update( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_name: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.IdentityProviderUpdateParameters - :param if_match: ETag of 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 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'IdentityProviderUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IdentityProviderContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore def delete( - self, resource_group_name, service_name, identity_provider_name, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified identity provider configuration. :param resource_group_name: The name of the resource group. @@ -411,62 +433,64 @@ def delete( :param service_name: The name of the API Management service. :type service_name: str :param identity_provider_name: Identity Provider Type identifier. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :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 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}'} # type: ignore def list_secrets( - self, resource_group_name, service_name, identity_provider_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + identity_provider_name, # type: Union[str, "models.IdentityProviderType"] + **kwargs # type: Any + ): + # type: (...) -> "models.ClientSecretContract" """Gets the client secret details of the Identity Provider. :param resource_group_name: The name of the resource group. @@ -474,59 +498,53 @@ 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. - Possible values include: 'facebook', 'google', 'microsoft', 'twitter', - 'aad', 'aadB2C' - :type identity_provider_name: str or - ~azure.mgmt.apimanagement.models.IdentityProviderType - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ClientSecretContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'identityProviderName': self._serialize.url("identity_provider_name", identity_provider_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ClientSecretContract', response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets'} + 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 505fff747273..1305009ef5e9 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,201 +1,211 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class IssueOperations(object): """IssueOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.IssueCollection"] """Lists a collection of issues 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| apiId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| title | filter - | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith - |
| description | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| authorName | filter | ge, le, - eq, ne, gt, lt | substringof, contains, startswith, endswith |
| - state | filter | eq | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of IssueContract - :rtype: - ~azure.mgmt.apimanagement.models.IssueContractPaged[~azure.mgmt.apimanagement.models.IssueContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.IssueCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('IssueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.IssueContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues'} # type: ignore def get( - self, resource_group_name, service_name, issue_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + issue_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.IssueContract" """Gets API Management issue details. :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 issue_id: Issue identifier. Must be unique in the current API - Management service instance. + :param issue_id: Issue identifier. Must be unique in the current API Management service + instance. :type issue_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: IssueContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.IssueContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IssueContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.IssueContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.IssueContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'issueId': self._serialize.url("issue_id", issue_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('IssueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('IssueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}'} + 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 92dea27d29d3..735ce2b238e8 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,476 +1,503 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class LoggerOperations(object): """LoggerOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.LoggerCollection"] """Lists a collection of loggers 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| description | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - loggerType | filter | eq | |
| resourceId | filter | ge, le, - eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of LoggerContract - :rtype: - ~azure.mgmt.apimanagement.models.LoggerContractPaged[~azure.mgmt.apimanagement.models.LoggerContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.LoggerCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LoggerCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('LoggerCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.LoggerContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, logger_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the logger specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + logger_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the logger 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 logger_id: Logger identifier. Must be unique in the API - Management service instance. + :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore def get( - self, resource_group_name, service_name, logger_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + logger_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.LoggerContract" """Gets the details of the logger 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 logger_id: Logger identifier. Must be unique in the API - Management service instance. + :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: LoggerContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.LoggerContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LoggerContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LoggerContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('LoggerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, logger_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + logger_id, # type: str + parameters, # type: "models.LoggerContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.LoggerContract" """Creates or Updates a logger. :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 logger_id: Logger identifier. Must be unique in the API - Management service instance. + :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str :param parameters: Create parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: LoggerContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.LoggerContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LoggerContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.LoggerContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.LoggerContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'LoggerContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('LoggerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('LoggerContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore def update( - self, resource_group_name, service_name, logger_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + logger_id, # type: str + if_match, # type: str + parameters, # type: "models.LoggerUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.LoggerContract" """Updates an existing logger. :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 logger_id: Logger identifier. Must be unique in the API - Management service instance. + :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.LoggerUpdateContract - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'LoggerUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('LoggerContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} # type: ignore def delete( - self, resource_group_name, service_name, logger_id, if_match, force=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + logger_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified logger. :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 logger_id: Logger identifier. Must be unique in the API - Management service instance. + :param logger_id: Logger identifier. Must be unique in the API Management service instance. :type logger_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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: Force deletion even if diagnostic is attached. - :type force: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'loggerId': self._serialize.url("logger_id", logger_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}'} + 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 7cc52f6fb5aa..3d57da6402a6 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,137 +1,156 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class NamedValueOperations(object): """NamedValueOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of NamedValues defined within a service instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.NamedValueCollection"] + """Lists a collection of named values 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 - |
|-------------|-------------|-------------|-------------|
| - 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 |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| tags | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of NamedValueContract - :rtype: - ~azure.mgmt.apimanagement.models.NamedValueContractPaged[~azure.mgmt.apimanagement.models.NamedValueContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.NamedValueCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('NamedValueCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.NamedValueContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, named_value_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the NamedValue specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the named value specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -139,57 +158,64 @@ def get_entity_tag( :type service_name: str :param named_value_id: Identifier of the NamedValue. :type named_value_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore def get( - self, resource_group_name, service_name, named_value_id, custom_headers=None, raw=False, **operation_config): - """Gets the details of the NamedValue specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.NamedValueContract" + """Gets the details of the named value specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -197,128 +223,135 @@ def get( :type service_name: str :param named_value_id: Identifier of the NamedValue. :type named_value_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: NamedValueContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamedValueContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('NamedValueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} - + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore def _create_or_update_initial( - self, resource_group_name, service_name, named_value_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + parameters, # type: "models.NamedValueCreateContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.NamedValueContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.NamedValueContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self._create_or_update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'NamedValueCreateContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('NamedValueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('NamedValueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - - def create_or_update( - self, resource_group_name, service_name, named_value_id, parameters, if_match=None, custom_headers=None, raw=False, polling=True, **operation_config): - """Creates or updates a NamedValue. + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + parameters, # type: "models.NamedValueCreateContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.NamedValueContract"] + """Creates or updates named value. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -327,116 +360,139 @@ def create_or_update( :param named_value_id: Identifier of the NamedValue. :type named_value_id: str :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns NamedValueContract or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.NamedValueContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.NamedValueContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._create_or_update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - named_value_id=named_value_id, - parameters=parameters, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - header_dict = { - 'ETag': 'str', - } - deserialized = self._deserialize('NamedValueContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + parameters=parameters, + if_match=if_match, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore def _update_initial( - self, resource_group_name, service_name, named_value_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + if_match, # type: str + parameters, # type: "models.NamedValueUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.NamedValueContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.NamedValueContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'NamedValueUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [200, 202, 204]: - raise models.ErrorResponseException(self._deserialize, response) + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} deserialized = None - header_dict = {} - if response.status_code == 200: - deserialized = self._deserialize('NamedValueContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - - def update( - self, resource_group_name, service_name, named_value_id, parameters, if_match, custom_headers=None, raw=False, polling=True, **operation_config): - """Updates the specific NamedValue. + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore + + def begin_update( + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + if_match, # type: str + parameters, # type: "models.NamedValueUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.NamedValueContract"] + """Updates the specific named value. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -444,63 +500,76 @@ def update( :type service_name: str :param named_value_id: Identifier of the NamedValue. :type named_value_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.NamedValueUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :param parameters: Update parameters. + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns NamedValueContract or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.NamedValueContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.NamedValueContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either NamedValueContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.NamedValueContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._update_initial( - resource_group_name=resource_group_name, - service_name=service_name, - named_value_id=named_value_id, - parameters=parameters, - if_match=if_match, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - header_dict = { - 'ETag': 'str', - } - deserialized = self._deserialize('NamedValueContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + service_name=service_name, + named_value_id=named_value_id, + if_match=if_match, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore def delete( - self, resource_group_name, service_name, named_value_id, if_match, custom_headers=None, raw=False, **operation_config): - """Deletes specific NamedValue from the API Management service instance. + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes specific named value from the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -508,59 +577,64 @@ def delete( :type service_name: str :param named_value_id: Identifier of the NamedValue. :type named_value_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}'} # type: ignore def list_value( - self, resource_group_name, service_name, named_value_id, custom_headers=None, raw=False, **operation_config): - """Gets the secret value of the NamedValue. + self, + resource_group_name, # type: str + service_name, # type: str + named_value_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.NamedValueSecretContract" + """Gets the secret of the named value specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -568,55 +642,52 @@ def list_value( :type service_name: str :param named_value_id: Identifier of the NamedValue. :type named_value_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PropertyValueContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PropertyValueContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamedValueSecretContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NamedValueSecretContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NamedValueSecretContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_value.metadata['url'] + url = self.list_value.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'namedValueId': self._serialize.url("named_value_id", named_value_id, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PropertyValueContract', response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('NamedValueSecretContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} + list_value.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue'} # 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 1d1470f7a5ce..d4ecb176e446 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,169 +1,174 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class NetworkStatusOperations(object): """NetworkStatusOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> List["models.NetworkStatusContractByLocation"] + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: - list[~azure.mgmt.apimanagement.models.NetworkStatusContractByLocation] - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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[~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$') + 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('[NetworkStatusContractByLocation]', response) + deserialized = self._deserialize('[NetworkStatusContractByLocation]', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus'} # type: ignore def list_by_location( - self, resource_group_name, service_name, location_name, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + location_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.NetworkStatusContract" + """Gets the Connectivity Status to the external resources on which the Api Management service + depends from inside the Cloud Service. This also returns the DNS Servers as visible to the + CloudService. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param location_name: Location in which the API Management service is - deployed. This is one of the Azure Regions like West US, East US, - South Central US. + :param location_name: Location in which the API Management service is deployed. This is one of + the Azure Regions like West US, East US, South Central US. :type location_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: NetworkStatusContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NetworkStatusContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NetworkStatusContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NetworkStatusContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_location.metadata['url'] + url = self.list_by_location.metadata['url'] # type: ignore path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'locationName': self._serialize.url("location_name", location_name, 'str', min_length=1) + 'locationName': self._serialize.url("location_name", location_name, 'str', min_length=1), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('NetworkStatusContract', response) + deserialized = self._deserialize('NetworkStatusContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus'} + 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 7642c25b90f7..c1fd0e050d96 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,45 +1,59 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class NotificationOperations(object): """NotificationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.NotificationCollection"] """Lists a collection of properties defined within a service instance. :param resource_group_name: The name of the resource group. @@ -50,212 +64,203 @@ def list_by_service( :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of NotificationContract - :rtype: - ~azure.mgmt.apimanagement.models.NotificationContractPaged[~azure.mgmt.apimanagement.models.NotificationContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.NotificationCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NotificationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('NotificationCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.NotificationContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications'} # type: ignore def get( - self, resource_group_name, service_name, notification_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + **kwargs # type: Any + ): + # type: (...) -> "models.NotificationContract" """Gets the details of the Notification 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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: NotificationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.NotificationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('NotificationContract', response) + deserialized = self._deserialize('NotificationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, notification_name, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.NotificationContract" """Create or Update API Management publisher notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :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. + :param notification_name: Notification Name Identifier. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: NotificationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.NotificationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NotificationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.NotificationContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.NotificationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('NotificationContract', response) + deserialized = self._deserialize('NotificationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}'} + 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 0010945f33a9..0081bc72bc3e 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,314 +1,312 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class NotificationRecipientEmailOperations(object): """NotificationRecipientEmailOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_notification( - self, resource_group_name, service_name, notification_name, custom_headers=None, raw=False, **operation_config): - """Gets the list of the Notification Recipient Emails subscribed to a - notification. + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + **kwargs # type: Any + ): + # type: (...) -> "models.RecipientEmailCollection" + """Gets the list of the Notification Recipient Emails subscribed to a notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecipientEmailCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_notification.metadata['url'] + url = self.list_by_notification.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecipientEmailCollection', response) + deserialized = self._deserialize('RecipientEmailCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} + list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails'} # type: ignore def check_entity_exists( - self, resource_group_name, service_name, notification_name, email, custom_headers=None, raw=False, **operation_config): - """Determine if Notification Recipient Email subscribed to the - notification. + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + email, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Determine if Notification Recipient Email subscribed to the notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName + :param notification_name: Notification Name Identifier. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.check_entity_exists.metadata['url'] + url = self.check_entity_exists.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, notification_name, email, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + email, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.RecipientEmailContract" """Adds the Email address to the list of Recipients for the Notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName + :param notification_name: Notification Name Identifier. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecipientEmailContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecipientEmailContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientEmailContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RecipientEmailContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RecipientEmailContract', response) + deserialized = self._deserialize('RecipientEmailContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('RecipientEmailContract', response) + deserialized = self._deserialize('RecipientEmailContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} # type: ignore def delete( - self, resource_group_name, service_name, notification_name, email, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + email, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Removes the email from the list of Notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName + :param notification_name: Notification Name Identifier. + :type notification_name: str or ~azure.mgmt.apimanagement.models.NotificationName :param email: Email identifier. :type email: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'email': self._serialize.url("email", email, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}'} + 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 584a10409e5f..c5293a2f28e8 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,318 +1,312 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class NotificationRecipientUserOperations(object): """NotificationRecipientUserOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_notification( - self, resource_group_name, service_name, notification_name, custom_headers=None, raw=False, **operation_config): - """Gets the list of the Notification Recipient User subscribed to the - notification. + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + **kwargs # type: Any + ): + # type: (...) -> "models.RecipientUserCollection" + """Gets the list of the Notification Recipient User subscribed to the notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :type notification_name: str or - ~azure.mgmt.apimanagement.models.NotificationName - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecipientUserCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.RecipientUserCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param notification_name: Notification Name Identifier. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_notification.metadata['url'] + url = self.list_by_notification.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('RecipientUserCollection', response) + deserialized = self._deserialize('RecipientUserCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} + list_by_notification.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers'} # type: ignore def check_entity_exists( - self, resource_group_name, service_name, notification_name, user_id, custom_headers=None, raw=False, **operation_config): - """Determine if the Notification Recipient User is subscribed to the - notification. + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Determine if the Notification Recipient User is subscribed to the notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :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. + :param notification_name: Notification Name Identifier. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: bool or ClientRawResponse if raw=true - :rtype: bool or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.check_entity_exists.metadata['url'] + url = self.check_entity_exists.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204, 404]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = (response.status_code == 204) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - return deserialized - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, notification_name, user_id, custom_headers=None, raw=False, **operation_config): - """Adds the API Management User to the list of Recipients for the - Notification. + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.RecipientUserContract" + """Adds the API Management User to the list of Recipients for the Notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :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. + :param notification_name: Notification Name Identifier. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: RecipientUserContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RecipientUserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.RecipientUserContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RecipientUserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('RecipientUserContract', response) + deserialized = self._deserialize('RecipientUserContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('RecipientUserContract', response) + deserialized = self._deserialize('RecipientUserContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} # type: ignore def delete( - self, resource_group_name, service_name, notification_name, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + notification_name, # type: Union[str, "models.NotificationName"] + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Removes the API Management user from the list of Notification. :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 notification_name: Notification Name Identifier. Possible - values include: 'RequestPublisherNotificationMessage', - 'PurchasePublisherNotificationMessage', - 'NewApplicationNotificationMessage', 'BCC', - 'NewIssuePublisherNotificationMessage', 'AccountClosedPublisher', - 'QuotaLimitApproachingPublisherNotificationMessage' - :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. + :param notification_name: Notification Name Identifier. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'notificationName': self._serialize.url("notification_name", notification_name, 'str'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}'} + 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 8f2b7565010d..6f080d6ed659 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,135 +1,154 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class OpenIdConnectProviderOperations(object): """OpenIdConnectProviderOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OpenIdConnectProviderCollection"] """Lists of all the OpenId Connect Providers. :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 |
+ :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 + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of OpenidConnectProviderContract - :rtype: - ~azure.mgmt.apimanagement.models.OpenidConnectProviderContractPaged[~azure.mgmt.apimanagement.models.OpenidConnectProviderContract] - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OpenIdConnectProviderCollection or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.apimanagement.models.OpenIdConnectProviderCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OpenIdConnectProviderCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('OpenIdConnectProviderCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.OpenidConnectProviderContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the openIdConnectProvider - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the openIdConnectProvider specified by its identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -137,57 +156,64 @@ def get_entity_tag( :type service_name: str :param opid: Identifier of the OpenID Connect Provider. :type opid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore def get( - self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): - """Gets specific OpenID Connect Provider. + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.OpenidConnectProviderContract" + """Gets specific OpenID Connect Provider without secrets. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -195,67 +221,66 @@ def get( :type service_name: str :param opid: Identifier of the OpenID Connect Provider. :type opid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OpenidConnectProviderContract or ClientRawResponse if - raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenidConnectProviderContract, or the result of cls(response) :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OpenidConnectProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, opid, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + parameters, # type: "models.OpenidConnectProviderContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.OpenidConnectProviderContract" """Creates or updates the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -265,83 +290,82 @@ def create_or_update( :param opid: Identifier of the OpenID Connect Provider. :type opid: str :param parameters: Create parameters. - :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. + :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. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: OpenidConnectProviderContract or ClientRawResponse if - raw=true + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OpenidConnectProviderContract, or the result of cls(response) :rtype: ~azure.mgmt.apimanagement.models.OpenidConnectProviderContract - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'OpenidConnectProviderContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('OpenidConnectProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('OpenidConnectProviderContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore def update( - self, resource_group_name, service_name, opid, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + if_match, # type: str + parameters, # type: "models.OpenidConnectProviderUpdateContract" + **kwargs # type: Any + ): + # type: (...) -> "models.OpenidConnectProviderContract" """Updates the specific OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -350,67 +374,77 @@ def update( :type service_name: str :param opid: Identifier of the OpenID Connect Provider. :type opid: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.OpenidConnectProviderUpdateContract - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'OpenidConnectProviderUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('OpenidConnectProviderContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore def delete( - self, resource_group_name, service_name, opid, if_match, custom_headers=None, raw=False, **operation_config): - """Deletes specific OpenID Connect Provider of the API Management service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes specific OpenID Connect Provider of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str @@ -418,58 +452,63 @@ def delete( :type service_name: str :param opid: Identifier of the OpenID Connect Provider. :type opid: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}'} # type: ignore def list_secrets( - self, resource_group_name, service_name, opid, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + opid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ClientSecretContract" """Gets the client secret details of the OpenID Connect Provider. :param resource_group_name: The name of the resource group. @@ -478,55 +517,52 @@ def list_secrets( :type service_name: str :param opid: Identifier of the OpenID Connect Provider. :type opid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ClientSecretContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClientSecretContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ClientSecretContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ClientSecretContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'opid': self._serialize.url("opid", opid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'opid': self._serialize.url("opid", opid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ClientSecretContract', response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ClientSecretContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets'} + 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 20c50ea27494..a6a874dba36b 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,68 +1,80 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class OperationOperations(object): """OperationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_tags( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, include_not_tagged_operations=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + include_not_tagged_operations=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagResourceCollection"] """Lists a collection of operations associated with tags. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| apiName - | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| description | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| method | filter | - ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | -
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int @@ -70,30 +82,36 @@ def list_by_tags( :type skip: int :param include_not_tagged_operations: Include not tagged Operations. :type include_not_tagged_operations: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagResourceContract - :rtype: - ~azure.mgmt.apimanagement.models.TagResourceContractPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_tags.metadata['url'] + url = self.list_by_tags.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -102,43 +120,35 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if include_not_tagged_operations is not None: query_parameters['includeNotTaggedOperations'] = self._serialize.query("include_not_tagged_operations", include_not_tagged_operations, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagResourceContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags'} + 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 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 9dd71e8a269c..89023d21ee09 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,105 +1,110 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyDescriptionOperations(object): """PolicyDescriptionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, scope=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + scope=None, # type: Optional[Union[str, "models.PolicyScopeContract"]] + **kwargs # type: Any + ): + # type: (...) -> "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. Possible values include: 'Tenant', - 'Product', 'Api', 'Operation', 'All' - :type scope: str or - ~azure.mgmt.apimanagement.models.PolicyScopeContract - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyDescriptionCollection or ClientRawResponse if raw=true + :param scope: Policy scope. + :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: ~azure.mgmt.apimanagement.models.PolicyDescriptionCollection - or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if scope is not None: - query_parameters['scope'] = self._serialize.query("scope", scope, 'PolicyScopeContract') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['scope'] = self._serialize.query("scope", scope, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyDescriptionCollection', response) + deserialized = self._deserialize('PolicyDescriptionCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_policy_operations.py index 3a64140c6a9f..bee52d8a8ed5 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,377 +1,398 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class PolicyOperations(object): """PolicyOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar policy_id: The identifier of the Policy. Constant value: "policy". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.policy_id = "policy" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyCollection" """Lists all the Global Policy definitions of the Api Management service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyCollection', response) + deserialized = self._deserialize('PolicyCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the Global policy definition in - the Api Management service. + self, + resource_group_name, # type: str + service_name, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the Global policy definition in the Api Management + service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore def get( - self, resource_group_name, service_name, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + format="xml", # type: Optional[Union[str, "models.PolicyExportFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Get the Global policy definition of the Api Management service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param format: Policy Export Format. Possible values include: 'xml', - 'rawxml' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyExportFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if format is not None: query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, value, if_match=None, format="xml", custom_headers=None, raw=False, **operation_config): - """Creates or updates the global policy configuration of the Api - Management service. + self, + resource_group_name, # type: str + service_name, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match=None, # type: Optional[str] + value=None, # type: Optional[str] + format="xml", # type: Optional[Union[str, "models.PolicyContentFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" + """Creates or updates the global policy configuration of the Api Management service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str :param value: Contents of the Policy as defined by the format. :type value: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. - :type if_match: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyContentFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PolicyContract(value=value, format=format) + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyContract') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} # type: ignore def delete( - self, resource_group_name, service_name, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the global policy configuration of the Api Management Service. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param policy_id: The identifier of the Policy. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}'} + 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/_product_api_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_product_api_operations.py index 2e8b6c46c519..b28cc6d1f99a 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,330 +1,358 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProductApiOperations(object): """ProductApiOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_product( - self, resource_group_name, service_name, product_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ApiCollection"] """Lists a collection of the APIs associated with a product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| path | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ApiContract - :rtype: - ~azure.mgmt.apimanagement.models.ApiContractPaged[~azure.mgmt.apimanagement.models.ApiContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ApiCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_product.metadata['url'] + url = self.list_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ApiCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ApiContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis'} + 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 def check_entity_exists( - self, resource_group_name, service_name, product_id, api_id, custom_headers=None, raw=False, **operation_config): - """Checks that API entity specified by identifier is associated with the - Product entity. + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks that API entity specified by identifier is associated with the Product entity. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.check_entity_exists.metadata['url'] + url = self.check_entity_exists.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, product_id, api_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ApiContract" """Adds an API to the specified product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ApiContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ApiContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ApiContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ApiContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ApiContract', response) + deserialized = self._deserialize('ApiContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ApiContract', response) + deserialized = self._deserialize('ApiContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} # type: ignore def delete( - self, resource_group_name, service_name, product_id, api_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + api_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified API from the specified product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}'} + 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 da974b742fac..c1297e6b6162 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,324 +1,354 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProductGroupOperations(object): """ProductGroupOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_product( - self, resource_group_name, service_name, product_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): - """Lists the collection of developer groups associated with the specified - product. + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.GroupCollection"] + """Lists the collection of developer groups associated with the specified product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | |
| displayName | - filter | eq, ne | |
| description | filter | eq, ne | | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| + description | filter | eq, ne | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GroupContract - :rtype: - ~azure.mgmt.apimanagement.models.GroupContractPaged[~azure.mgmt.apimanagement.models.GroupContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.GroupCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_product.metadata['url'] + url = self.list_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GroupContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups'} + 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 def check_entity_exists( - self, resource_group_name, service_name, product_id, group_id, custom_headers=None, raw=False, **operation_config): - """Checks that Group entity specified by identifier is associated with the - Product entity. + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Checks that Group entity specified by identifier is associated with the Product entity. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.check_entity_exists.metadata['url'] + url = self.check_entity_exists.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} + if cls: + return cls(pipeline_response, None, {}) + + return 200 <= response.status_code <= 299 + check_entity_exists.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, product_id, group_id, custom_headers=None, raw=False, **operation_config): - """Adds the association between the specified developer group with the - specified product. + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GroupContract" + """Adds the association between the specified developer group with the specified product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GroupContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GroupContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GroupContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GroupContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('GroupContract', response) + deserialized = self._deserialize('GroupContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('GroupContract', response) + deserialized = self._deserialize('GroupContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} # type: ignore def delete( - self, resource_group_name, service_name, product_id, group_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + group_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the association between the specified group and product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param group_id: Group identifier. Must be unique in the current API - Management service instance. + :param group_id: Group identifier. Must be unique in the current API Management service + instance. :type group_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'groupId': self._serialize.url("group_id", group_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}'} + 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 4f46d390296f..f03fe82d683f 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,95 +1,114 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProductOperations(object): """ProductOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, expand_groups=None, tags=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + expand_groups=None, # type: Optional[bool] + tags=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ProductCollection"] """Lists a collection of products 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| state | filter - | eq | |
| groups | expand | | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | |
| groups | expand | | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :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. + :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. :type tags: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ProductContract - :rtype: - ~azure.mgmt.apimanagement.models.ProductContractPaged[~azure.mgmt.apimanagement.models.ProductContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.ProductCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -100,411 +119,435 @@ def prepare_request(next_link=None): query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') if tags is not None: query_parameters['tags'] = self._serialize.query("tags", tags, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ProductCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ProductContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, product_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the product specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the product 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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore def get( - self, resource_group_name, service_name, product_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.ProductContract" """Gets the details of the product 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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ProductContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ProductContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProductContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('ProductContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, product_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + parameters, # type: "models.ProductContract" + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ProductContract" """Creates or Updates a product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str :param parameters: Create or update parameters. :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. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ProductContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.ProductContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ProductContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.ProductContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ProductContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ProductContract') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('ProductContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('ProductContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore def update( - self, resource_group_name, service_name, product_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + if_match, # type: str + parameters, # type: "models.ProductUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.ProductContract" """Update existing product details. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.ProductUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'ProductUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('ProductContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore def delete( - self, resource_group_name, service_name, product_id, if_match, delete_subscriptions=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + if_match, # type: str + delete_subscriptions=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None """Delete product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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: Delete existing subscriptions associated - with the product or not. + :param delete_subscriptions: Delete existing subscriptions associated with the product or not. :type delete_subscriptions: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if delete_subscriptions is not None: query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}'} # type: ignore def list_by_tags( - self, resource_group_name, service_name, filter=None, top=None, skip=None, include_not_tagged_products=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + include_not_tagged_products=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagResourceCollection"] """Lists a collection of products associated with tags. :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 |
| - 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 |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| state | filter | eq | substringof, contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int @@ -512,30 +555,35 @@ def list_by_tags( :type skip: int :param include_not_tagged_products: Include not tagged Products. :type include_not_tagged_products: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagResourceContract - :rtype: - ~azure.mgmt.apimanagement.models.TagResourceContractPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_tags.metadata['url'] + url = self.list_by_tags.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -544,41 +592,36 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if include_not_tagged_products is not None: query_parameters['includeNotTaggedProducts'] = self._serialize.query("include_not_tagged_products", include_not_tagged_products, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagResourceContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags'} + return ItemPaged( + get_next, extract_data + ) + 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 c1092714069e..0502a42ecccc 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,395 +1,422 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProductPolicyOperations(object): """ProductPolicyOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar policy_id: The identifier of the Policy. Constant value: "policy". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.policy_id = "policy" - - self.config = config + self._config = config def list_by_product( - self, resource_group_name, service_name, product_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyCollection" """Get the policy configuration at the Product level. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyCollection + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_product.metadata['url'] + url = self.list_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyCollection', response) + deserialized = self._deserialize('PolicyCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, product_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + **kwargs # type: Any + ): + # type: (...) -> bool """Get the ETag of the policy configuration at the Product level. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore def get( - self, resource_group_name, service_name, product_id, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + format="xml", # type: Optional[Union[str, "models.PolicyExportFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Get the policy configuration at the Product level. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param format: Policy Export Format. Possible values include: 'xml', - 'rawxml' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyExportFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param format: Policy Export Format. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if format is not None: query_parameters['format'] = self._serialize.query("format", format, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, product_id, value, if_match=None, format="xml", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match=None, # type: Optional[str] + value=None, # type: Optional[str] + format="xml", # type: Optional[Union[str, "models.PolicyContentFormat"]] + **kwargs # type: Any + ): + # type: (...) -> "models.PolicyContract" """Creates or updates policy configuration for the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str + :param policy_id: The identifier of the Policy. + :type policy_id: str or ~azure.mgmt.apimanagement.models.PolicyIdName + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str :param value: Contents of the Policy as defined by the format. :type value: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. - :type if_match: str - :param format: Format of the policyContent. Possible values include: - 'xml', 'xml-link', 'rawxml', 'rawxml-link' - :type format: str or - ~azure.mgmt.apimanagement.models.PolicyContentFormat - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PolicyContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PolicyContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param format: Format of the policyContent. + :type format: str or ~azure.mgmt.apimanagement.models.PolicyContentFormat + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PolicyContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PolicyContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PolicyContract(value=value, format=format) + cls = kwargs.pop('cls', None) # type: ClsType["models.PolicyContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PolicyContract(value=value, format=format) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PolicyContract') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PolicyContract') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('PolicyContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PolicyContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} # type: ignore def delete( - self, resource_group_name, service_name, product_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + policy_id, # type: Union[str, "models.PolicyIdName"] + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the policy configuration at the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param policy_id: The identifier of the Policy. + :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 - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'policyId': self._serialize.url("self.policy_id", self.policy_id, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'policyId': self._serialize.url("policy_id", policy_id, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}'} + 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 9a6079a07e70..624192412788 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,140 +1,152 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ProductSubscriptionsOperations(object): """ProductSubscriptionsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, product_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionCollection"] """Lists the collection of subscriptions to the specified product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - stateComment | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| ownerId | filter | ge, le, eq, - ne, gt, lt | substringof, contains, startswith, endswith |
| - scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| productId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
| user | expand | - | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of SubscriptionContract - :rtype: - ~azure.mgmt.apimanagement.models.SubscriptionContractPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + 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 0d4220b0cfd6..5b9a611b6a71 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,181 +1,194 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class QuotaByCounterKeysOperations(object): """QuotaByCounterKeysOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, quota_counter_key, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + quota_counter_key, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.QuotaCounterCollection" + """Lists a collection of current quota counter periods associated with the counter-key configured + in the policy on the specified service instance. The api does not support paging yet. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the - result of expression defined in counter-key attribute of the - quota-by-key policy.For Example, if you specify counter-key="boo" in - the policy, then it’s accessible by "boo" counter key. But if it’s - defined as counter-key="@("b"+"a")" then it will be accessible by "ba" - key + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: QuotaCounterCollection or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('QuotaCounterCollection', response) + deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore def update( - self, resource_group_name, service_name, quota_counter_key, calls_count=None, kb_transferred=None, custom_headers=None, raw=False, **operation_config): - """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. + self, + resource_group_name, # type: str + service_name, # type: str + quota_counter_key, # type: str + calls_count=None, # type: Optional[int] + kb_transferred=None, # type: Optional[float] + **kwargs # type: Any + ): + # type: (...) -> "models.QuotaCounterCollection" + """Updates all the quota counter values specified with the existing quota counter key to a value + in the specified service instance. This should be used for reset of the quota counter values. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the - result of expression defined in counter-key attribute of the - quota-by-key policy.For Example, if you specify counter-key="boo" in - the policy, then it’s accessible by "boo" counter key. But if it’s - defined as counter-key="@("b"+"a")" then it will be accessible by "ba" - key + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str :param calls_count: Number of times Counter was called. :type calls_count: int :param kb_transferred: Data Transferred in KiloBytes. :type kb_transferred: float - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterCollection, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterCollection + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.QuotaCounterValueContractProperties(calls_count=calls_count, kb_transferred=kb_transferred) + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.QuotaCounterValueUpdateContract(calls_count=calls_count, kb_transferred=kb_transferred) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'QuotaCounterValueContractProperties') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'QuotaCounterValueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}'} # type: ignore 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 db29c87e0c04..83d8bedc1a78 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,130 +1,142 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class QuotaByPeriodKeysOperations(object): """QuotaByPeriodKeysOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def get( - self, resource_group_name, service_name, quota_counter_key, quota_period_key, custom_headers=None, raw=False, **operation_config): - """Gets the value of the quota counter associated with the counter-key in - the policy for the specific period in service instance. + self, + resource_group_name, # type: str + service_name, # type: str + quota_counter_key, # type: str + quota_period_key, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.QuotaCounterContract" + """Gets the value of the quota counter associated with the counter-key in the policy for the + specific period in service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param quota_counter_key: Quota counter key identifier.This is the - result of expression defined in counter-key attribute of the - quota-by-key policy.For Example, if you specify counter-key="boo" in - the policy, then it’s accessible by "boo" counter key. But if it’s - defined as counter-key="@("b"+"a")" then it will be accessible by "ba" - key + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str :param quota_period_key: Quota period key identifier. :type quota_period_key: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: QuotaCounterContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('QuotaCounterContract', response) + deserialized = self._deserialize('QuotaCounterContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore def update( - self, resource_group_name, service_name, quota_counter_key, quota_period_key, calls_count=None, kb_transferred=None, custom_headers=None, raw=False, **operation_config): - """Updates an existing quota counter value in the specified service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + quota_counter_key, # type: str + quota_period_key, # type: str + calls_count=None, # type: Optional[int] + kb_transferred=None, # type: Optional[float] + **kwargs # type: Any + ): + # type: (...) -> "models.QuotaCounterContract" + """Updates an existing quota counter value 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 quota_counter_key: Quota counter key identifier.This is the - result of expression defined in counter-key attribute of the - quota-by-key policy.For Example, if you specify counter-key="boo" in - the policy, then it’s accessible by "boo" counter key. But if it’s - defined as counter-key="@("b"+"a")" then it will be accessible by "ba" - key + :param quota_counter_key: Quota counter key identifier.This is the result of expression defined + in counter-key attribute of the quota-by-key policy.For Example, if you specify counter- + key="boo" in the policy, then it’s accessible by "boo" counter key. But if it’s defined as + counter-key="@("b"+"a")" then it will be accessible by "ba" key. :type quota_counter_key: str :param quota_period_key: Quota period key identifier. :type quota_period_key: str @@ -132,54 +144,58 @@ def update( :type calls_count: int :param kb_transferred: Data Transferred in KiloBytes. :type kb_transferred: float - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaCounterContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.QuotaCounterContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.QuotaCounterValueContractProperties(calls_count=calls_count, kb_transferred=kb_transferred) + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaCounterContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.QuotaCounterValueUpdateContract(calls_count=calls_count, kb_transferred=kb_transferred) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'quotaCounterKey': self._serialize.url("quota_counter_key", quota_counter_key, 'str'), 'quotaPeriodKey': self._serialize.url("quota_period_key", quota_period_key, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'QuotaCounterValueContractProperties') - - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) - - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'QuotaCounterValueUpdateContract') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaCounterContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}'} # type: ignore 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 e2c5b8b6b2ef..41955b481594 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,110 +1,122 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class RegionOperations(object): """RegionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.RegionListResult"] """Lists all azure regions in which the service exists. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RegionContract - :rtype: - ~azure.mgmt.apimanagement.models.RegionContractPaged[~azure.mgmt.apimanagement.models.RegionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.RegionListResult] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RegionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RegionListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RegionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions'} + return ItemPaged( + get_next, extract_data + ) + 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 ce71756ffbd8..6652cc881168 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,46 +1,62 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class ReportsOperations(object): """ReportsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_api( - self, resource_group_name, service_name, filter, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by API. :param resource_group_name: The name of the resource group. @@ -55,29 +71,35 @@ def list_by_api( :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_api.metadata['url'] + url = self.list_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -85,74 +107,69 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} + return ItemPaged( + get_next, extract_data + ) + list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi'} # type: ignore def list_by_user( - self, resource_group_name, service_name, filter, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by User. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| displayName | select, - orderBy | | |
| userId | select, filter | eq | | -
| apiRegion | filter | eq | |
| productId | filter | eq - | |
| subscriptionId | filter | eq | |
| apiId | - filter | eq | |
| operationId | filter | eq | |
| - callCountSuccess | select, orderBy | | |
| - callCountBlocked | select, orderBy | | |
| - callCountFailed | select, orderBy | | |
| callCountOther - | select, orderBy | | |
| callCountTotal | select, - orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | - select | | |
| apiTimeAvg | select, orderBy | | | -
| apiTimeMin | select | | |
| apiTimeMax | select | - | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | - | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| userId | + select, filter | eq | |
| apiRegion | filter | eq | |
| productId | filter | + eq | |
| subscriptionId | filter | eq | |
| apiId | filter | eq | | +
| operationId | filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -160,29 +177,35 @@ def list_by_user( :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_user.metadata['url'] + url = self.list_by_user.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -190,74 +213,69 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} + return ItemPaged( + get_next, extract_data + ) + list_by_user.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser'} # type: ignore def list_by_operation( - self, resource_group_name, service_name, filter, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by API Operations. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| displayName | select, - orderBy | | |
| apiRegion | filter | eq | |
| - userId | filter | eq | |
| productId | filter | eq | | -
| subscriptionId | filter | eq | |
| apiId | filter | eq - | |
| operationId | select, filter | eq | |
| - callCountSuccess | select, orderBy | | |
| - callCountBlocked | select, orderBy | | |
| - callCountFailed | select, orderBy | | |
| callCountOther - | select, orderBy | | |
| callCountTotal | select, - orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | - select | | |
| apiTimeAvg | select, orderBy | | | -
| apiTimeMin | select | | |
| apiTimeMax | select | - | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | - | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | select, filter | eq | |
| callCountSuccess | select, orderBy | | + |
| callCountBlocked | select, orderBy | | |
| callCountFailed | select, + orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -265,29 +283,35 @@ def list_by_operation( :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_operation.metadata['url'] + url = self.list_by_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -295,72 +319,68 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} + return ItemPaged( + get_next, extract_data + ) + list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation'} # type: ignore def list_by_product( - self, resource_group_name, service_name, filter, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by Product. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| displayName | select, - orderBy | | |
| apiRegion | filter | eq | |
| - userId | filter | eq | |
| productId | select, filter | eq | - |
| subscriptionId | filter | eq | |
| callCountSuccess - | select, orderBy | | |
| callCountBlocked | select, - orderBy | | |
| callCountFailed | select, orderBy | | - |
| callCountOther | select, orderBy | | |
| - callCountTotal | select, orderBy | | |
| bandwidth | - select, orderBy | | |
| cacheHitsCount | select | | - |
| cacheMissCount | select | | |
| apiTimeAvg | - select, orderBy | | |
| apiTimeMin | select | | | -
| apiTimeMax | select | | |
| serviceTimeAvg | - select | | |
| serviceTimeMin | select | | | -
| serviceTimeMax | select | | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | select, filter | eq + | |
| subscriptionId | filter | eq | |
| callCountSuccess | select, orderBy | + | |
| callCountBlocked | select, orderBy | | |
| callCountFailed | + select, orderBy | | |
| callCountOther | select, orderBy | | |
| + callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | | | +
| cacheHitsCount | select | | |
| cacheMissCount | select | | | +
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -368,29 +388,35 @@ def list_by_product( :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_product.metadata['url'] + url = self.list_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -398,172 +424,169 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} + return ItemPaged( + get_next, extract_data + ) + list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct'} # type: ignore def list_by_geo( - self, resource_group_name, service_name, filter, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by geography. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| country | select | | - |
| region | select | | |
| zip | select | | - |
| apiRegion | filter | eq | |
| userId | filter | eq | - |
| productId | filter | eq | |
| subscriptionId | - filter | eq | |
| apiId | filter | eq | |
| - operationId | filter | eq | |
| callCountSuccess | select | - | |
| callCountBlocked | select | | |
| - callCountFailed | select | | |
| callCountOther | select - | | |
| bandwidth | select, orderBy | | |
| - cacheHitsCount | select | | |
| cacheMissCount | select | - | |
| apiTimeAvg | select | | |
| apiTimeMin | - select | | |
| apiTimeMax | select | | |
| - serviceTimeAvg | select | | |
| serviceTimeMin | select | - | |
| serviceTimeMax | select | | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| country | select | | |
| region | select | | + |
| zip | select | | |
| apiRegion | filter | eq | |
| userId | + filter | eq | |
| productId | filter | eq | |
| subscriptionId | filter | eq + | |
| apiId | filter | eq | |
| operationId | filter | eq | |
| + callCountSuccess | select | | |
| callCountBlocked | select | | |
| + callCountFailed | select | | |
| callCountOther | select | | |
| + bandwidth | select, orderBy | | |
| cacheHitsCount | select | | |
| + cacheMissCount | select | | |
| apiTimeAvg | select | | |
| + apiTimeMin | select | | |
| apiTimeMax | select | | |
| + serviceTimeAvg | select | | |
| serviceTimeMin | select | | |
| + serviceTimeMax | select | | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_geo.metadata['url'] + url = self.list_by_geo.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} + return ItemPaged( + get_next, extract_data + ) + list_by_geo.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo'} # type: ignore def list_by_subscription( - self, resource_group_name, service_name, filter, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by subscription. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| displayName | select, - orderBy | | |
| apiRegion | filter | eq | |
| - userId | select, filter | eq | |
| productId | select, filter - | eq | |
| subscriptionId | select, filter | eq | | -
| callCountSuccess | select, orderBy | | |
| - callCountBlocked | select, orderBy | | |
| - callCountFailed | select, orderBy | | |
| callCountOther - | select, orderBy | | |
| callCountTotal | select, - orderBy | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | - select | | |
| apiTimeAvg | select, orderBy | | | -
| apiTimeMin | select | | |
| apiTimeMax | select | - | |
| serviceTimeAvg | select | | |
| - serviceTimeMin | select | | |
| serviceTimeMax | select | - | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| displayName | select, orderBy | | |
| apiRegion | + filter | eq | |
| userId | select, filter | eq | |
| productId | select, + filter | eq | |
| subscriptionId | select, filter | eq | |
| callCountSuccess + | select, orderBy | | |
| callCountBlocked | select, orderBy | | |
| + callCountFailed | select, orderBy | | |
| callCountOther | select, orderBy | | + |
| callCountTotal | select, orderBy | | |
| bandwidth | select, orderBy | + | |
| cacheHitsCount | select | | |
| cacheMissCount | select | | + |
| apiTimeAvg | select, orderBy | | |
| apiTimeMin | select | | | +
| apiTimeMax | select | | |
| serviceTimeAvg | select | | |
| + serviceTimeMin | select | | |
| serviceTimeMax | select | | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -571,29 +594,35 @@ def list_by_subscription( :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_subscription.metadata['url'] + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -601,108 +630,110 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} + return ItemPaged( + get_next, extract_data + ) + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription'} # type: ignore def list_by_time( - self, resource_group_name, service_name, filter, interval, top=None, skip=None, orderby=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + interval, # type: datetime.timedelta + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + orderby=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReportCollection"] """Lists report records by Time. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter, select | ge, le | |
| interval | select | - | |
| apiRegion | filter | eq | |
| userId | filter - | eq | |
| productId | filter | eq | |
| - subscriptionId | filter | eq | |
| apiId | filter | eq | - |
| operationId | filter | eq | |
| callCountSuccess | - select | | |
| callCountBlocked | select | | | -
| callCountFailed | select | | |
| callCountOther | - select | | |
| bandwidth | select, orderBy | | | -
| cacheHitsCount | select | | |
| cacheMissCount | - select | | |
| apiTimeAvg | select | | |
| - apiTimeMin | select | | |
| apiTimeMax | select | | - |
| serviceTimeAvg | select | | |
| serviceTimeMin | - select | | |
| serviceTimeMax | select | | | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter, select | ge, le | |
| interval | select | | |
| apiRegion | + filter | eq | |
| userId | filter | eq | |
| productId | filter | eq | | +
| subscriptionId | filter | eq | |
| apiId | filter | eq | |
| + operationId | filter | eq | |
| callCountSuccess | select | | |
| + callCountBlocked | select | | |
| callCountFailed | select | | |
| + callCountOther | select | | |
| bandwidth | select, orderBy | | |
| + cacheHitsCount | select | | |
| cacheMissCount | select | | |
| + apiTimeAvg | select | | |
| apiTimeMin | select | | |
| apiTimeMax | + select | | |
| serviceTimeAvg | select | | |
| serviceTimeMin | + select | | |
| serviceTimeMax | select | | |
. :type filter: str - :param interval: By time interval. Interval must be multiple of 15 - minutes and may not be zero. The value should be in ISO 8601 format - (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be - used to convert TimeSpan to a valid interval string: - XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). - :type interval: timedelta + :param interval: By time interval. Interval must be multiple of 15 minutes and may not be zero. + The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This + code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new + TimeSpan(hours, minutes, seconds)). + :type interval: ~datetime.timedelta :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int :param orderby: OData order by query option. :type orderby: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.ReportRecordContractPaged[~azure.mgmt.apimanagement.models.ReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.ReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_time.metadata['url'] + url = self.list_by_time.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) @@ -711,132 +742,128 @@ def prepare_request(next_link=None): if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('ReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.ReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} + return ItemPaged( + get_next, extract_data + ) + list_by_time.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime'} # type: ignore def list_by_request( - self, resource_group_name, service_name, filter, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter, # type: str + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.RequestReportCollection"] """Lists report records by Request. :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 - |
|-------------|-------------|-------------|-------------|
| - timestamp | filter | ge, le | |
| apiId | filter | eq | | -
| operationId | filter | eq | |
| productId | filter | - eq | |
| userId | filter | eq | |
| apiRegion | - filter | eq | |
| subscriptionId | filter | eq | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| timestamp | + filter | ge, le | |
| apiId | filter | eq | |
| operationId | filter | eq | + |
| productId | filter | eq | |
| userId | filter | eq | |
| apiRegion | + filter | eq | |
| subscriptionId | filter | eq | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of RequestReportRecordContract - :rtype: - ~azure.mgmt.apimanagement.models.RequestReportRecordContractPaged[~azure.mgmt.apimanagement.models.RequestReportRecordContract] - :raises: :class:`CloudError` + :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[~azure.mgmt.apimanagement.models.RequestReportCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.RequestReportCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_request.metadata['url'] + url = self.list_by_request.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('RequestReportCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - return response + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.RequestReportRecordContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_request.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest'} + return ItemPaged( + get_next, extract_data + ) + 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 515301379741..602eb2f952c6 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,297 +1,316 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SignInSettingsOperations(object): """SignInSettingsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def get_entity_tag( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state (Etag) version of the SignInSettings. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PortalSigninSettings" """Get Sign In Settings for the Portal. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalSigninSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSigninSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSigninSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalSigninSettings', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore def update( - self, resource_group_name, service_name, if_match, enabled=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + if_match, # type: str + enabled=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> None """Update Sign-In 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 if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 enabled: Redirect Anonymous users to the Sign-In page. :type enabled: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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 """ - parameters = models.PortalSigninSettings(enabled=enabled) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSigninSettings(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PortalSigninSettings') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSigninSettings') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} # type: ignore def create_or_update( - self, resource_group_name, service_name, if_match=None, enabled=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + if_match=None, # type: Optional[str] + enabled=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> "models.PortalSigninSettings" """Create or Update Sign-In 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 if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str :param enabled: Redirect Anonymous users to the Sign-In page. :type enabled: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalSigninSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSigninSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSigninSettings + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PortalSigninSettings(enabled=enabled) + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSigninSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSigninSettings(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PortalSigninSettings') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSigninSettings') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalSigninSettings', response) + deserialized = self._deserialize('PortalSigninSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin'} + 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 01e8bd6c0d9d..eeb4c50dd354 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,303 +1,322 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SignUpSettingsOperations(object): """SignUpSettingsOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def get_entity_tag( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state (Etag) version of the SignUpSettings. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.PortalSignupSettings" """Get Sign Up Settings for the Portal. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalSignupSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSignupSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSignupSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalSignupSettings', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore def update( - self, resource_group_name, service_name, if_match, enabled=None, terms_of_service=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + if_match, # type: str + enabled=None, # type: Optional[bool] + terms_of_service=None, # type: Optional["models.TermsOfServiceProperties"] + **kwargs # type: Any + ): + # type: (...) -> None """Update Sign-Up 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 if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 enabled: Allow users to sign up on a developer portal. :type enabled: bool :param terms_of_service: Terms of service contract properties. - :type terms_of_service: - ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :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 """ - parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PortalSignupSettings') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSignupSettings') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} + if cls: + return cls(pipeline_response, None, {}) + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} # type: ignore def create_or_update( - self, resource_group_name, service_name, if_match=None, enabled=None, terms_of_service=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + if_match=None, # type: Optional[str] + enabled=None, # type: Optional[bool] + terms_of_service=None, # type: Optional["models.TermsOfServiceProperties"] + **kwargs # type: Any + ): + # type: (...) -> "models.PortalSignupSettings" """Create or Update Sign-Up 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 if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str :param enabled: Allow users to sign up on a developer portal. :type enabled: bool :param terms_of_service: Terms of service contract properties. - :type terms_of_service: - ~azure.mgmt.apimanagement.models.TermsOfServiceProperties - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: PortalSignupSettings or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :type terms_of_service: ~azure.mgmt.apimanagement.models.TermsOfServiceProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PortalSignupSettings, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.PortalSignupSettings + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + cls = kwargs.pop('cls', None) # type: ClsType["models.PortalSignupSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.PortalSignupSettings(enabled=enabled, terms_of_service=terms_of_service) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'PortalSignupSettings') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'PortalSignupSettings') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('PortalSignupSettings', response) + deserialized = self._deserialize('PortalSignupSettings', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup'} + 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 c6dbaa892536..878855b5372e 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,673 +1,735 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class SubscriptionOperations(object): """SubscriptionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionCollection"] """Lists all subscriptions of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - stateComment | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| ownerId | filter | ge, le, eq, - ne, gt, lt | substringof, contains, startswith, endswith |
| - scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| productId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| state | filter | eq | |
| user | expand | - | |
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| productId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| state | filter | eq | |
| user | expand | | + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of SubscriptionContract - :rtype: - ~azure.mgmt.apimanagement.models.SubscriptionContractPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, sid, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the apimanagement subscription - specified by its identifier. + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the apimanagement subscription specified by its + identifier. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore def get( - self, resource_group_name, service_name, sid, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionContract" """Gets the specified Subscription entity. :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 sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SubscriptionContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, sid, parameters, notify=None, if_match=None, custom_headers=None, raw=False, **operation_config): - """Creates or updates the subscription of specified user to the specified - product. + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + parameters, # type: "models.SubscriptionCreateParameters" + notify=None, # type: Optional[bool] + if_match=None, # type: Optional[str] + app_type=None, # type: Optional[Union[str, "models.AppType"]] + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionContract" + """Creates or updates the subscription of specified user to the specified product. :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 sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str :param parameters: Create parameters. - :type parameters: - ~azure.mgmt.apimanagement.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 false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. :type notify: bool - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SubscriptionContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.SubscriptionContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if notify is not None: query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'SubscriptionCreateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('SubscriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('SubscriptionContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore def update( - self, resource_group_name, service_name, sid, parameters, if_match, notify=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + if_match, # type: str + parameters, # type: "models.SubscriptionUpdateParameters" + notify=None, # type: Optional[bool] + app_type=None, # type: Optional[Union[str, "models.AppType"]] + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionContract" """Updates the details of a subscription 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 sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.SubscriptionUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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: ~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 false, do not send any email notification for change of state of subscription + * If true, send email notification of change of state of subscription. :type notify: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if notify is not None: query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'SubscriptionUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore def delete( - self, resource_group_name, service_name, sid, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes the specified subscription. :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 sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}'} # type: ignore def regenerate_primary_key( - self, resource_group_name, service_name, sid, custom_headers=None, raw=False, **operation_config): - """Regenerates primary key of existing subscription of the API Management - service instance. + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Regenerates primary key of existing subscription of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_primary_key.metadata['url'] + url = self.regenerate_primary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey'} + 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 def regenerate_secondary_key( - self, resource_group_name, service_name, sid, custom_headers=None, raw=False, **operation_config): - """Regenerates secondary key of existing subscription of the API - Management service instance. + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Regenerates secondary key of existing subscription of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_secondary_key.metadata['url'] + url = self.regenerate_secondary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} + regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey'} # type: ignore def list_secrets( - self, resource_group_name, service_name, sid, custom_headers=None, raw=False, **operation_config): - """Gets the subscription keys. + self, + resource_group_name, # type: str + service_name, # type: str + sid, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.SubscriptionKeysContract" + """Gets the specified Subscription keys. :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 sid: Subscription entity Identifier. The entity represents the - association between a user and a product in API Management. + :param sid: Subscription entity Identifier. The entity represents the association between a + user and a product in API Management. :type sid: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: SubscriptionKeysContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SubscriptionKeysContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.SubscriptionKeysContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionKeysContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'sid': self._serialize.url("sid", sid, 'str', max_length=256, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'sid': self._serialize.url("sid", sid, 'str', max_length=256, min_length=0, pattern=r'^[^*#&+:<>?]+$'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('SubscriptionKeysContract', response) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('SubscriptionKeysContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets'} + 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 fcae3c76c755..ae091104a4da 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,1200 +1,1273 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagOperations(object): """TagOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_operation( - self, resource_group_name, service_name, api_id, operation_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagCollection"] """Lists all Tags associated with the Operation. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. + :param operation_id: Operation identifier within an API. Must be unique in the current API + Management service instance. :type operation_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagContract - :rtype: - ~azure.mgmt.apimanagement.models.TagContractPaged[~azure.mgmt.apimanagement.models.TagContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_operation.metadata['url'] + url = self.list_by_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags'} + 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 def get_entity_state_by_operation( - self, resource_group_name, service_name, api_id, operation_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. - :type operation_id: str - :param tag_id: Tag identifier. Must be unique in the current API + :param operation_id: Operation identifier within an API. Must be unique in the current API Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_state_by_operation.metadata['url'] + url = self.get_entity_state_by_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_state_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} + 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 def get_by_operation( - self, resource_group_name, service_name, api_id, operation_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Get tag associated with the Operation. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. - :type operation_id: str - :param tag_id: Tag identifier. Must be unique in the current API + :param operation_id: Operation identifier within an API. Must be unique in the current API Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_by_operation.metadata['url'] + url = self.get_by_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} + get_by_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore def assign_to_operation( - self, resource_group_name, service_name, api_id, operation_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Assign tag to the Operation. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. - :type operation_id: str - :param tag_id: Tag identifier. Must be unique in the current API + :param operation_id: Operation identifier within an API. Must be unique in the current API Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.assign_to_operation.metadata['url'] + url = self.assign_to_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) + deserialized = self._deserialize('TagContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagContract', response) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} + assign_to_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} # type: ignore def detach_from_operation( - self, resource_group_name, service_name, api_id, operation_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + operation_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Detach the tag from the Operation. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param operation_id: Operation identifier within an API. Must be - unique in the current API Management service instance. - :type operation_id: str - :param tag_id: Tag identifier. Must be unique in the current API + :param operation_id: Operation identifier within an API. Must be unique in the current API Management service instance. + :type operation_id: str + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.detach_from_operation.metadata['url'] + url = self.detach_from_operation.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'operationId': self._serialize.url("operation_id", operation_id, 'str', max_length=80, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - detach_from_operation.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}'} + 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 def list_by_api( - self, resource_group_name, service_name, api_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagCollection"] """Lists all Tags associated with the API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param 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 |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagContract - :rtype: - ~azure.mgmt.apimanagement.models.TagContractPaged[~azure.mgmt.apimanagement.models.TagContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_api.metadata['url'] + url = self.list_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags'} + 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 def get_entity_state_by_api( - self, resource_group_name, service_name, api_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state version of the tag 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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_state_by_api.metadata['url'] + url = self.get_entity_state_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_state_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore def get_by_api( - self, resource_group_name, service_name, api_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Get tag associated with the API. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_by_api.metadata['url'] + url = self.get_by_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} + get_by_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore def assign_to_api( - self, resource_group_name, service_name, api_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Assign tag to the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.assign_to_api.metadata['url'] + url = self.assign_to_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} + assign_to_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore def detach_from_api( - self, resource_group_name, service_name, api_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + api_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Detach the tag from the Api. :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 api_id: API revision identifier. Must be unique in the current - API Management service instance. Non-current revision has ;rev=n as a - suffix where n is the revision number. + :param api_id: API revision identifier. Must be unique in the current API Management service + instance. Non-current revision has ;rev=n as a suffix where n is the revision number. :type api_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.detach_from_api.metadata['url'] + url = self.detach_from_api.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'apiId': self._serialize.url("api_id", api_id, 'str', max_length=256, min_length=1, pattern=r'^[^*#&+:<>?]+$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} + detach_from_api.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}'} # type: ignore def list_by_product( - self, resource_group_name, service_name, product_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagCollection"] """Lists all Tags associated with the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
+ :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 |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagContract - :rtype: - ~azure.mgmt.apimanagement.models.TagContractPaged[~azure.mgmt.apimanagement.models.TagContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_product.metadata['url'] + url = self.list_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags'} + 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 def get_entity_state_by_product( - self, resource_group_name, service_name, product_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state version of the tag 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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_state_by_product.metadata['url'] + url = self.get_entity_state_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_state_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore def get_by_product( - self, resource_group_name, service_name, product_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Get tag associated with the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_by_product.metadata['url'] + url = self.get_by_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} + get_by_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore def assign_to_product( - self, resource_group_name, service_name, product_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Assign tag to the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.assign_to_product.metadata['url'] + url = self.assign_to_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.put(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) + deserialized = self._deserialize('TagContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagContract', response) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} + assign_to_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore def detach_from_product( - self, resource_group_name, service_name, product_id, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + product_id, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Detach the tag from the Product. :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 product_id: Product identifier. Must be unique in the current - API Management service instance. + :param product_id: Product identifier. Must be unique in the current API Management service + instance. :type product_id: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.detach_from_product.metadata['url'] + url = self.detach_from_product.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'productId': self._serialize.url("product_id", product_id, 'str', max_length=256, min_length=1), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} + detach_from_product.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}'} # type: ignore def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, scope=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + scope=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagCollection"] """Lists a collection of tags 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 |
+ :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 + |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param scope: Scope like 'apis', 'products' or 'apis/{apiId} + :param scope: Scope like 'apis', 'products' or 'apis/{apiId}. :type scope: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagContract - :rtype: - ~azure.mgmt.apimanagement.models.TagContractPaged[~azure.mgmt.apimanagement.models.TagContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -1203,386 +1276,401 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if scope is not None: query_parameters['scope'] = self._serialize.query("scope", scope, 'str') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - return response + return pipeline_response - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagContractPaged(internal_paging, self._deserialize.dependencies, header_dict) - - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags'} # type: ignore def get_entity_state( - self, resource_group_name, service_name, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool """Gets the entity state version of the tag 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 tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_state.metadata['url'] + url = self.get_entity_state.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore def get( - self, resource_group_name, service_name, tag_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + tag_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Gets the details of the tag 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 tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, tag_id, display_name, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + tag_id, # type: str + if_match=None, # type: Optional[str] + display_name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Creates a tag. :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 tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. + :type if_match: str :param display_name: Tag name. :type display_name: str - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. - :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TagContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.TagContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.TagCreateUpdateParameters(display_name=display_name) + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagCreateUpdateParameters(display_name=display_name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'TagCreateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('TagContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore def update( - self, resource_group_name, service_name, tag_id, if_match, display_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + tag_id, # type: str + if_match, # type: str + display_name=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.TagContract" """Updates the details of the tag 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 tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 display_name: Tag name. :type display_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TagContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.TagContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.TagCreateUpdateParameters(display_name=display_name) + cls = kwargs.pop('cls', None) # type: ClsType["models.TagContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.TagCreateUpdateParameters(display_name=display_name) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'TagCreateUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct body - body_content = self._serialize.body(parameters, 'TagCreateUpdateParameters') + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('TagContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} # type: ignore def delete( - self, resource_group_name, service_name, tag_id, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + tag_id, # type: str + if_match, # type: str + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific tag of the API Management service instance. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param tag_id: Tag identifier. Must be unique in the current API - Management service instance. + :param tag_id: Tag identifier. Must be unique in the current API Management service instance. :type tag_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'tagId': self._serialize.url("tag_id", tag_id, 'str', max_length=80, min_length=1, pattern=r'^[^*#&+:<>?]+$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}'} + 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 968cfec99052..6765d56020aa 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,142 +1,151 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TagResourceOperations(object): """TagResourceOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.TagResourceCollection"] """Lists a collection of resources associated with tags. :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 - |
|-------------|-------------|-------------|-------------|
| - aid | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| displayName | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| apiName | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| apiRevision | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| path | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| description | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| method | filter | - ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith | -
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| terms | filter | ge, le, eq, - ne, gt, lt | substringof, contains, startswith, endswith |
| - state | filter | eq | |
| isCurrent | filter | eq | | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| aid | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | + substringof, contains, startswith, endswith |
| state | filter | eq | |
| isCurrent + | filter | eq | |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of TagResourceContract - :rtype: - ~azure.mgmt.apimanagement.models.TagResourceContractPaged[~azure.mgmt.apimanagement.models.TagResourceContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.TagResourceCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.TagResourceCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('TagResourceCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.TagResourceContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources'} + return ItemPaged( + get_next, extract_data + ) + 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 56879020577a..844d0087aca0 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,279 +1,299 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantAccessGitOperations(object): """TenantAccessGitOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar access_name: The identifier of the Access configuration. Constant value: "access". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.access_name = "access" - - self.config = config + self._config = config def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> "models.AccessInformationContract" """Gets the Git access configuration for the tenant. Without secrets. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AccessInformationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('AccessInformationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git'} # type: ignore def regenerate_primary_key( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> None """Regenerate primary access key for GIT. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_primary_key.metadata['url'] + url = self.regenerate_primary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey'} + 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 def regenerate_secondary_key( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> None """Regenerate secondary access key for GIT. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_secondary_key.metadata['url'] + url = self.regenerate_secondary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey'} + 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 def list_secrets( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> "models.AccessInformationContract" """Gets the Git access configuration for the tenant. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AccessInformationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('AccessInformationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/listSecrets'} + list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/listSecrets'} # 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 ac6665edb7de..a22bfafe33fd 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,401 +1,445 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantAccessOperations(object): """TenantAccessOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar access_name: The identifier of the Access configuration. Constant value: "access". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.access_name = "access" - - self.config = config + self._config = config def get_entity_tag( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> bool """Tenant access metadata. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} + if cls: + return cls(pipeline_response, None, response_headers) + + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore def get( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> "models.AccessInformationContract" """Get tenant access information details without secrets. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AccessInformationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('AccessInformationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore def update( - self, resource_group_name, service_name, if_match, enabled=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + if_match, # type: str + enabled=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> "models.AccessInformationContract" """Update tenant access information details. :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 if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param access_name: The identifier of the Access configuration. + :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 enabled: Determines whether direct access is enabled. :type enabled: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessInformationContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.AccessInformationUpdateParameters(enabled=enabled) + cls = kwargs.pop('cls', None) # type: ClsType["models.AccessInformationContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.AccessInformationUpdateParameters(enabled=enabled) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'accessName': self._serialize.url("access_name", access_name, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'AccessInformationUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct body - body_content = self._serialize.body(parameters, 'AccessInformationUpdateParameters') + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}'} # type: ignore def regenerate_primary_key( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> None """Regenerate primary access key. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_primary_key.metadata['url'] + url = self.regenerate_primary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} + regenerate_primary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey'} # type: ignore def regenerate_secondary_key( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> None """Regenerate secondary access key. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.regenerate_secondary_key.metadata['url'] + url = self.regenerate_secondary_key.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} + regenerate_secondary_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey'} # type: ignore def list_secrets( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + access_name, # type: Union[str, "models.AccessIdName"] + **kwargs # type: Any + ): + # type: (...) -> "models.AccessInformationContract" """Get tenant access information details. :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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: AccessInformationContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.AccessInformationContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param access_name: The identifier of the Access configuration. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.list_secrets.metadata['url'] + url = self.list_secrets.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'accessName': self._serialize.url("self.access_name", self.access_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'accessName': self._serialize.url("access_name", access_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('AccessInformationContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('AccessInformationContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - list_secrets.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets'} + 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 e08d0f7c5e8f..067a6e06c6b5 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,436 +1,528 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError -from msrest.polling import LROPoller, NoPolling -from msrestazure.polling.arm_polling import ARMPolling +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class TenantConfigurationOperations(object): """TenantConfigurationOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". - :ivar configuration_name: The identifier of the Git Configuration Operation. Constant value: "configuration". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - self.configuration_name = "configuration" - - self.config = config - + self._config = config def _deploy_initial( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeployConfigurationParameters(branch=branch, force=force) + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.OperationResultContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeployConfigurationParameters(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.deploy.metadata['url'] + url = self._deploy_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'configurationName': self._serialize.url("self.configuration_name", self.configuration_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'DeployConfigurationParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', response) + deserialized = self._deserialize('OperationResultContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def deploy( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, polling=True, **operation_config): - """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. + _deploy_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore + + def begin_deploy( + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.OperationResultContract"] + """This operation applies changes from the specified Git branch to the configuration database. + This is a long running operation and could take several minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param branch: The name of the Git branch from which the configuration - is to be deployed to the configuration database. + :param configuration_name: The identifier of the Git Configuration Operation. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. :type branch: str - :param force: The value enforcing deleting subscriptions to products - that are deleted in this update. + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. :type force: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns OperationResultContract - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.OperationResultContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._deploy_initial( - resource_group_name=resource_group_name, - service_name=service_name, - branch=branch, - force=force, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('OperationResultContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._deploy_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_deploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy'} # type: ignore def _save_initial( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, **operation_config): - parameters = models.SaveConfigurationParameter(branch=branch, force=force) + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.OperationResultContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.SaveConfigurationParameter(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.save.metadata['url'] + url = self._save_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'configurationName': self._serialize.url("self.configuration_name", self.configuration_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'SaveConfigurationParameter') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'SaveConfigurationParameter') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', response) + deserialized = self._deserialize('OperationResultContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def save( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, polling=True, **operation_config): - """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. + _save_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore + + def begin_save( + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.OperationResultContract"] + """This operation creates a commit with the current configuration snapshot to the specified branch + in the repository. This is a long running operation and could take several minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param branch: The name of the Git branch in which to commit the - current configuration snapshot. + :param configuration_name: The identifier of the Git Configuration Operation. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch in which to commit the current configuration + snapshot. :type branch: str - :param force: The value if true, the current configuration database is - committed to the Git repository, even if the Git repository has newer - changes that would be overwritten. + :param force: The value if true, the current configuration database is committed to the Git + repository, even if the Git repository has newer changes that would be overwritten. :type force: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns OperationResultContract - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.OperationResultContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._save_initial( - resource_group_name=resource_group_name, - service_name=service_name, - branch=branch, - force=force, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('OperationResultContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._save_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} - + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_save.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save'} # type: ignore def _validate_initial( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, **operation_config): - parameters = models.DeployConfigurationParameters(branch=branch, force=force) + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Optional["models.OperationResultContract"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.OperationResultContract"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.DeployConfigurationParameters(branch=branch, force=force) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.validate.metadata['url'] + url = self._validate_initial.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'configurationName': self._serialize.url("self.configuration_name", self.configuration_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'DeployConfigurationParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'DeployConfigurationParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 202]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('OperationResultContract', response) + deserialized = self._deserialize('OperationResultContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - - def validate( - self, resource_group_name, service_name, branch, force=None, custom_headers=None, raw=False, polling=True, **operation_config): - """This operation validates the changes in the specified Git branch. This - is a long running operation and could take several minutes to complete. + _validate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore + + def begin_validate( + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + branch=None, # type: Optional[str] + force=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.OperationResultContract"] + """This operation validates the changes in the specified Git branch. This is a long running + operation and could take several minutes to complete. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param branch: The name of the Git branch from which the configuration - is to be deployed to the configuration database. + :param configuration_name: The identifier of the Git Configuration Operation. + :type configuration_name: str or ~azure.mgmt.apimanagement.models.ConfigurationIdName + :param branch: The name of the Git branch from which the configuration is to be deployed to the + configuration database. :type branch: str - :param force: The value enforcing deleting subscriptions to products - that are deleted in this update. + :param force: The value enforcing deleting subscriptions to products that are deleted in this + update. :type force: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: The poller return type is ClientRawResponse, the - direct response alongside the deserialized response - :param polling: True for ARMPolling, False for no polling, or a + :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: True for ARMPolling, False for no polling, or a polling object for personal polling strategy - :return: An instance of LROPoller that returns OperationResultContract - or ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.apimanagement.models.OperationResultContract] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.apimanagement.models.OperationResultContract]] - :raises: - :class:`ErrorResponseException` + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either OperationResultContract or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.apimanagement.models.OperationResultContract] + :raises ~azure.core.exceptions.HttpResponseError: """ - raw_result = self._validate_initial( - resource_group_name=resource_group_name, - service_name=service_name, - branch=branch, - force=force, - custom_headers=custom_headers, - raw=True, - **operation_config + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationResultContract"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval ) - - def get_long_running_output(response): - deserialized = self._deserialize('OperationResultContract', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._validate_initial( + resource_group_name=resource_group_name, + service_name=service_name, + configuration_name=configuration_name, + branch=branch, + force=force, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('OperationResultContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - lro_delay = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_validate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate'} # type: ignore def get_sync_state( - self, resource_group_name, service_name, custom_headers=None, raw=False, **operation_config): - """Gets the status of the most recent synchronization between the - configuration database and the Git repository. + self, + resource_group_name, # type: str + service_name, # type: str + configuration_name, # type: Union[str, "models.ConfigurationIdName"] + **kwargs # type: Any + ): + # type: (...) -> "models.TenantConfigurationSyncStateContract" + """Gets the status of the most recent synchronization between the configuration database and the + Git repository. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: TenantConfigurationSyncStateContract or ClientRawResponse if - raw=true - :rtype: - ~azure.mgmt.apimanagement.models.TenantConfigurationSyncStateContract - or ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` + :param configuration_name: The identifier of the Git Configuration Operation. + :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: ~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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_sync_state.metadata['url'] + url = self.get_sync_state.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'configurationName': self._serialize.url("self.configuration_name", self.configuration_name, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('TenantConfigurationSyncStateContract', response) + deserialized = self._deserialize('TenantConfigurationSyncStateContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_sync_state.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState'} + 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/_user_confirmation_password_operations.py b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/operations/_user_confirmation_password_operations.py index 193c9b412fe3..43ba91ac6994 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,95 +1,112 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class UserConfirmationPasswordOperations(object): """UserConfirmationPasswordOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def send( - self, resource_group_name, service_name, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + app_type=None, # type: Optional[Union[str, "models.AppType"]] + **kwargs # type: Any + ): + # type: (...) -> None """Sends confirmation. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.send.metadata['url'] + url = self.send.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - send.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send'} + 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 947c714ca66f..68f9fe93438d 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,133 +1,147 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class UserGroupOperations(object): """UserGroupOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, user_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.GroupCollection"] """Lists all user groups. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - description | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
+ :param filter: | Field | Usage | Supported operators | Supported + functions + |
|-------------|------------------------|-----------------------------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of GroupContract - :rtype: - ~azure.mgmt.apimanagement.models.GroupContractPaged[~azure.mgmt.apimanagement.models.GroupContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.GroupCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GroupCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('GroupCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.GroupContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups'} + return ItemPaged( + get_next, extract_data + ) + 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 ac5de590d1b6..99f8c972a2d2 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,114 +1,126 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class UserIdentitiesOperations(object): """UserIdentitiesOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.UserIdentityCollection"] """List of all user identities. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of UserIdentityContract - :rtype: - ~azure.mgmt.apimanagement.models.UserIdentityContractPaged[~azure.mgmt.apimanagement.models.UserIdentityContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.UserIdentityCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserIdentityCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('UserIdentityCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.UserIdentityContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities'} + return ItemPaged( + get_next, extract_data + ) + 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 2fd37c3c6203..4438ee282e74 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,65 +1,77 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class UserOperations(object): """UserOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list_by_service( - self, resource_group_name, service_name, filter=None, top=None, skip=None, expand_groups=None, custom_headers=None, raw=False, **operation_config): - """Lists a collection of registered users in the specified service - instance. + self, + resource_group_name, # type: str + service_name, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + expand_groups=None, # type: Optional[bool] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.UserCollection"] + """Lists a collection of registered users 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 filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| firstName | filter | ge, le, eq, ne, gt, - lt | substringof, contains, startswith, endswith |
| lastName | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
| email | filter | ge, le, eq, ne, gt, lt | - substringof, contains, startswith, endswith |
| state | filter | - eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | - |
| note | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| groups | expand | | | -
+ :param filter: | Field | Usage | Supported operators | Supported + functions |
|-------------|-------------|-------------|-------------|
| name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName + | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| email | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | + |
| note | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
| groups | expand | | |
. :type filter: str :param top: Number of records to return. :type top: int @@ -67,30 +79,35 @@ def list_by_service( :type skip: int :param expand_groups: Detailed Group in response. :type expand_groups: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of UserContract - :rtype: - ~azure.mgmt.apimanagement.models.UserContractPaged[~azure.mgmt.apimanagement.models.UserContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.UserCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list_by_service.metadata['url'] + url = self.list_by_service.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: @@ -99,536 +116,562 @@ def prepare_request(next_link=None): query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) if expand_groups is not None: query_parameters['expandGroups'] = self._serialize.query("expand_groups", expand_groups, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('UserCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.UserContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} + return ItemPaged( + get_next, extract_data + ) + list_by_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users'} # type: ignore def get_entity_tag( - self, resource_group_name, service_name, user_id, custom_headers=None, raw=False, **operation_config): - """Gets the entity state (Etag) version of the user specified by its - identifier. + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> bool + """Gets the entity state (Etag) version of the user 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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get_entity_tag.metadata['url'] + url = self.get_entity_tag.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.head(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + if cls: + return cls(pipeline_response, None, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - client_raw_response.add_headers({ - 'ETag': 'str', - }) - return client_raw_response - get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} + return 200 <= response.status_code <= 299 + get_entity_tag.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore def get( - self, resource_group_name, service_name, user_id, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.UserContract" """Gets the details of the user 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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: UserContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.UserContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.get.metadata['url'] + url = self.get.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.get(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('UserContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore def create_or_update( - self, resource_group_name, service_name, user_id, parameters, if_match=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + parameters, # type: "models.UserCreateParameters" + notify=None, # type: Optional[bool] + if_match=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.UserContract" """Creates or Updates a user. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :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: - ~azure.mgmt.apimanagement.models.UserCreateParameters - :param if_match: ETag of the Entity. Not required when creating an - entity, but required when updating an entity. + :type parameters: ~azure.mgmt.apimanagement.models.UserCreateParameters + :param notify: Send an Email notification to the User. + :type notify: bool + :param if_match: ETag of the Entity. Not required when creating an entity, but required when + updating an entity. :type if_match: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: UserContract or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.UserContract or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserContract, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserContract + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.UserContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.create_or_update.metadata['url'] + url = self.create_or_update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + if notify is not None: + query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'UserCreateParameters') - - # Construct and send request - request = self._client.put(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 201]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - header_dict = {} - deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('UserContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) + if response.status_code == 201: - deserialized = self._deserialize('UserContract', response) - header_dict = { - 'ETag': 'str', - } + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - client_raw_response.add_headers(header_dict) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore def update( - self, resource_group_name, service_name, user_id, parameters, if_match, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + if_match, # type: str + parameters, # type: "models.UserUpdateParameters" + **kwargs # type: Any + ): + # type: (...) -> "models.UserContract" """Updates the details of the user 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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param parameters: Update parameters. - :type parameters: - ~azure.mgmt.apimanagement.models.UserUpdateParameters - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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 dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param parameters: Update parameters. + :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: ~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', {})) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + # Construct URL - url = self.update.metadata['url'] + url = self.update.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct body + body_content_kwargs = {} # type: Dict[str, Any] body_content = self._serialize.body(parameters, 'UserUpdateParameters') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response - # Construct and send request - request = self._client.patch(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('UserContract', pipeline_response) - if response.status_code not in [204]: - raise models.ErrorResponseException(self._deserialize, response) + if cls: + return cls(pipeline_response, deserialized, response_headers) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore def delete( - self, resource_group_name, service_name, user_id, if_match, delete_subscriptions=None, notify=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + if_match, # type: str + delete_subscriptions=None, # type: Optional[bool] + notify=None, # type: Optional[bool] + app_type=None, # type: Optional[Union[str, "models.AppType"]] + **kwargs # type: Any + ): + # type: (...) -> None """Deletes specific user. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param if_match: ETag of the Entity. ETag should match the current - entity state from the header response of the GET request or it should - be * for unconditional update. + :param if_match: ETag of 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. :type delete_subscriptions: bool :param notify: Send an Account Closed Email notification to the User. :type notify: bool - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: None or ClientRawResponse if raw=true - :rtype: None or ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param app_type: Determines the type of application which send the create user request. Default + is legacy publisher portal. + :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', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.delete.metadata['url'] + url = self.delete.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if delete_subscriptions is not None: query_parameters['deleteSubscriptions'] = self._serialize.query("delete_subscriptions", delete_subscriptions, 'bool') if notify is not None: query_parameters['notify'] = self._serialize.query("notify", notify, 'bool') - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if app_type is not None: + query_parameters['appType'] = self._serialize.query("app_type", app_type, 'str') # Construct headers - header_parameters = {} - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) + header_parameters = {} # type: Dict[str, Any] header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - # Construct and send request request = self._client.delete(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200, 204]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}'} # type: ignore def generate_sso_url( - self, resource_group_name, service_name, user_id, custom_headers=None, raw=False, **operation_config): - """Retrieves a redirection URL containing an authentication token for - signing a given user into the developer portal. + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.GenerateSsoUrlResult" + """Retrieves a redirection URL containing an authentication token for signing a given user into + the developer portal. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param service_name: The name of the API Management service. :type service_name: str - :param user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: GenerateSsoUrlResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GenerateSsoUrlResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.GenerateSsoUrlResult + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.GenerateSsoUrlResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + # Construct URL - url = self.generate_sso_url.metadata['url'] + url = self.generate_sso_url.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = self._client.post(url, query_parameters, header_parameters) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('GenerateSsoUrlResult', response) + deserialized = self._deserialize('GenerateSsoUrlResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} + generate_sso_url.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl'} # type: ignore def get_shared_access_token( - self, resource_group_name, service_name, user_id, expiry, key_type="primary", custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + key_type=None, # type: Optional[Union[str, "models.KeyType"]] + expiry=None, # type: Optional[datetime.datetime] + **kwargs # type: Any + ): + # type: (...) -> "models.UserTokenResult" """Gets the Shared Access Authorization Token for the User. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str :param key_type: The Key to be used to generate token for user. - Possible values include: 'primary', 'secondary' :type key_type: str or ~azure.mgmt.apimanagement.models.KeyType - :param expiry: The Expiry time of the Token. Maximum token expiry time - is set to 30 days. The date conforms to the following format: - `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard. - :type expiry: datetime - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: UserTokenResult or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult or - ~msrest.pipeline.ClientRawResponse - :raises: - :class:`ErrorResponseException` + :param expiry: The Expiry time of the Token. Maximum token expiry time is set to 30 days. The + date conforms to the following format: ``yyyy-MM-ddTHH:mm:ssZ`` as specified by the ISO 8601 + standard. + :type expiry: ~datetime.datetime + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UserTokenResult, or the result of cls(response) + :rtype: ~azure.mgmt.apimanagement.models.UserTokenResult + :raises: ~azure.core.exceptions.HttpResponseError """ - parameters = models.UserTokenParameters(key_type=key_type, expiry=expiry) + cls = kwargs.pop('cls', None) # type: ClsType["models.UserTokenResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _parameters = models.UserTokenParameters(key_type=key_type, expiry=expiry) + api_version = "2020-06-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" # Construct URL - url = self.get_shared_access_token.metadata['url'] + url = self.get_shared_access_token.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(parameters, 'UserTokenParameters') - - # Construct and send request - request = self._client.post(url, query_parameters, header_parameters, body_content) - response = self._client.send(request, stream=False, **operation_config) + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(_parameters, 'UserTokenParameters') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('UserTokenResult', response) + deserialized = self._deserialize('UserTokenResult', pipeline_response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + if cls: + return cls(pipeline_response, deserialized, {}) return deserialized - get_shared_access_token.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token'} + 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 cbf13b40c7e8..69c8747ae83e 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,139 +1,150 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# +# Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is -# regenerated. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings -import uuid -from msrest.pipeline import ClientRawResponse +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] class UserSubscriptionOperations(object): """UserSubscriptionOperations operations. - You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.apimanagement.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. - :ivar api_version: Version of the API to be used with the client request. Constant value: "2019-12-01". """ models = models def __init__(self, client, config, serializer, deserializer): - self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2019-12-01" - - self.config = config + self._config = config def list( - self, resource_group_name, service_name, user_id, filter=None, top=None, skip=None, custom_headers=None, raw=False, **operation_config): + self, + resource_group_name, # type: str + service_name, # type: str + user_id, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skip=None, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.SubscriptionCollection"] """Lists the collection of subscriptions of the specified user. :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 user_id: User identifier. Must be unique in the current API - Management service instance. + :param user_id: User identifier. Must be unique in the current API Management service instance. :type user_id: str - :param filter: | Field | Usage | Supported operators - | Supported functions - |
|-------------|-------------|-------------|-------------|
| - name | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| displayName | filter | ge, le, eq, ne, - gt, lt | substringof, contains, startswith, endswith |
| - stateComment | filter | ge, le, eq, ne, gt, lt | substringof, - contains, startswith, endswith |
| ownerId | filter | ge, le, eq, - ne, gt, lt | substringof, contains, startswith, endswith |
| - scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, - startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt - | substringof, contains, startswith, endswith |
| productId | - filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, - endswith |
+ :param filter: | Field | Usage | Supported operators | Supported functions + |
|-------------|------------------------|-----------------------------------|
|name | + filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + |
|displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + endswith |
|stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|ownerId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, + startswith, endswith |
|productId | filter | ge, le, eq, ne, gt, lt | substringof, + contains, startswith, endswith |
. :type filter: str :param top: Number of records to return. :type top: int :param skip: Number of records to skip. :type skip: int - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of SubscriptionContract - :rtype: - ~azure.mgmt.apimanagement.models.SubscriptionContractPaged[~azure.mgmt.apimanagement.models.SubscriptionContract] - :raises: - :class:`ErrorResponseException` + :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[~azure.mgmt.apimanagement.models.SubscriptionCollection] + :raises: ~azure.core.exceptions.HttpResponseError """ + cls = kwargs.pop('cls', None) # type: ClsType["models.SubscriptionCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-06-01-preview" + accept = "application/json" + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + if not next_link: # Construct URL - url = self.list.metadata['url'] + url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'serviceName': self._serialize.url("service_name", service_name, 'str', max_length=50, min_length=1, pattern=r'^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$'), 'userId': self._serialize.url("user_id", user_id, 'str', max_length=80, min_length=1), - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} + query_parameters = {} # type: Dict[str, Any] if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) if skip is not None: query_parameters['$skip'] = self._serialize.query("skip", skip, 'int', minimum=0) - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = self._client.get(url, query_parameters, header_parameters) else: url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters, header_parameters) + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) return request - def internal_paging(next_link=None): + def extract_data(pipeline_response): + deserialized = self._deserialize('SubscriptionCollection', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): request = prepare_request(next_link) - response = self._client.send(request, stream=False, **operation_config) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response if response.status_code not in [200]: - raise models.ErrorResponseException(self._deserialize, response) - - return response + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - # Deserialize response - header_dict = None - if raw: - header_dict = {} - deserialized = models.SubscriptionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + return pipeline_response - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions'} # type: ignore diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/py.typed b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/azure/mgmt/apimanagement/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py b/sdk/apimanagement/azure-mgmt-apimanagement/setup.py index 071df946dd93..7dc03aca0c99 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/setup.py +++ b/sdk/apimanagement/azure-mgmt-apimanagement/setup.py @@ -36,7 +36,7 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) @@ -79,8 +79,8 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'msrestazure>=0.4.32,<2.0.0', 'azure-common~=1.1', + 'azure-mgmt-core>=1.2.0,<2.0.0' ], extras_require={ ":python_version<'3.0'": ['azure-mgmt-nspkg'], diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_apiservice2.yaml b/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_apiservice2.yaml new file mode 100644 index 000000000000..51f60e457856 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_apiservice2.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: '{"tags": {"tag1": "value1", "tag2": "value2", "tag3": "value3"}, "sku": + {"name": "Premium", "capacity": 1}, "location": "eastus", "properties": {"hostnameConfigurations": + [{"type": "Proxy", "hostName": "gateway1.msitesting.net", "encodedCertificate": + "****** Base 64 Encoded Certificate ************", "certificatePassword": "Password", + "defaultSslBinding": true}, {"type": "Management", "hostName": "mgmt.msitesting.net", + "encodedCertificate": "****** Base 64 Encoded Certificate ************", "certificatePassword": + "Password"}, {"type": "Portal", "hostName": "portal1.msitesting.net", "encodedCertificate": + "****** Base 64 Encoded Certificate ************", "certificatePassword": "Password"}], + "additionalLocations": [{"location": "East US", "sku": {"name": "Premium", "capacity": + 1}, "disableGateway": true}], "virtualNetworkType": "None", "apiVersionConstraint": + {"minApiVersion": "2019-01-01"}, "publisherEmail": "apim@autorestsdk.com", "publisherName": + "autorestsdk"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '977' + Content-Type: + - application/json + User-Agent: + - azsdk-python-mgmt-apimanagement/1.0.0b1 Python/3.6.9 (Linux-4.19.76-linuxkit-x86_64-with-Ubuntu-18.04-bionic) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_apimanagement_test_apiservice22500e21/providers/Microsoft.ApiManagement/service/apiservice2500e21?api-version=2020-06-01-preview + response: + body: + string: '{"error":{"code":"InvalidParameters","message":"Invalid parameter: + Cannot have two services in the same location ''East US''.","details":null,"innerError":null}}' + headers: + cache-control: + - no-cache + content-length: + - '159' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 27 Oct 2020 07:37:23 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1196' + status: + code: 400 + message: Bad Request +version: 1 diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_usr.yaml b/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_usr.yaml new file mode 100644 index 000000000000..e570566278e8 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/tests/recordings/test_apimanagement.test_usr.yaml @@ -0,0 +1,47 @@ +interactions: +- request: + body: '{"properties": {"email": "foobar@outlook.com", "firstName": "foo", "lastName": + "bar", "confirmation": "signup"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '112' + Content-Type: + - application/json + User-Agent: + - azsdk-python-mgmt-apimanagement/1.0.0b1 Python/3.6.9 (Linux-4.19.76-linuxkit-x86_64-with-Ubuntu-18.04-bionic) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_apimanagement_test_usr9b7e0b1e/providers/Microsoft.ApiManagement/service/pyuser9b7e0b1e/users/123?api-version=2020-06-01-preview + response: + body: + string: '{"error":{"code":"ResourceNotFound","message":"The Resource ''Microsoft.ApiManagement/service/pyuser9b7e0b1e'' + under resource group ''test_apimanagement_test_usr9b7e0b1e'' was not found. + For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}' + headers: + cache-control: + - no-cache + content-length: + - '253' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 27 Oct 2020 07:05:20 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-failure-cause: + - gateway + status: + code: 404 + message: Not Found +version: 1 diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/tests/test_apimanagement.py b/sdk/apimanagement/azure-mgmt-apimanagement/tests/test_apimanagement.py new file mode 100644 index 000000000000..fd87214e9e68 --- /dev/null +++ b/sdk/apimanagement/azure-mgmt-apimanagement/tests/test_apimanagement.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + + +import unittest +import azure.mgmt.apimanagement +from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer + +AZURE_LOCATION = 'eastus' + +class MgmtApimanagementTest(AzureMgmtTestCase): + + def setUp(self): + super(MgmtApimanagementTest, self).setUp() + self.mgmt_client = self.create_mgmt_client( + azure.mgmt.apimanagement.ApiManagementClient + ) + + @unittest.skip('Bad request') + @ResourceGroupPreparer(location=AZURE_LOCATION) + def test_apiservice3(self, resource_group): + # create + SERVICE_NAME = self.get_resource_name('apiservice') + BODY = { + "location": AZURE_LOCATION, + } + result = self.mgmt_client.api_management_service.begin_create_or_update(resource_group.name, SERVICE_NAME, BODY) + result.result() + + # get + self.mgmt_client.api_management_service.get(resource_group.name, SERVICE_NAME) + + # update + BODY = { + "properties": { + "customProperties": { + "Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": "false" + } + } + } + result = self.mgmt_client.api_management_service.begin_update(resource_group.name, SERVICE_NAME, BODY) + result.result() + + # delete + result = self.mgmt_client.api_management_service.delete(resource_group.name, SERVICE_NAME) + result.result() + + +# ------------------------------------------------------------------------------ +if __name__ == '__main__': + unittest.main() From 329ae5dde0319a0f90411c8e3daf7a9b579d74ef Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Tue, 17 Nov 2020 16:13:00 +0800 Subject: [PATCH 2/2] Update README.md --- .../azure-mgmt-apimanagement/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/apimanagement/azure-mgmt-apimanagement/README.md b/sdk/apimanagement/azure-mgmt-apimanagement/README.md index 08d5087827ee..5304e9ad26a8 100644 --- a/sdk/apimanagement/azure-mgmt-apimanagement/README.md +++ b/sdk/apimanagement/azure-mgmt-apimanagement/README.md @@ -4,11 +4,16 @@ This is the Microsoft Azure API Management Client Library. This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). - # Usage - -For code examples, see [API Management](https://docs.microsoft.com/python/api/overview/azure/) -on docs.microsoft.com. + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [API Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) # Provide Feedback