From 44415bdfc154e31a8289817f8ac004a21033a64b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 25 May 2022 10:08:31 +0000 Subject: [PATCH] CodeGen from PR 19192 in Azure/azure-rest-api-specs update-for-typescript.md (#19192) --- .../azure-mgmt-confidentialledger/_meta.json | 11 +- .../azure/mgmt/confidentialledger/__init__.py | 9 +- .../_confidential_ledger.py | 95 ++- .../mgmt/confidentialledger/_configuration.py | 31 +- .../mgmt/confidentialledger/_metadata.json | 43 +- .../azure/mgmt/confidentialledger/_patch.py | 31 + .../azure/mgmt/confidentialledger/_vendor.py | 27 + .../azure/mgmt/confidentialledger/_version.py | 2 +- .../mgmt/confidentialledger/aio/__init__.py | 5 + .../aio/_confidential_ledger.py | 83 +- .../confidentialledger/aio/_configuration.py | 18 +- .../mgmt/confidentialledger/aio/_patch.py | 31 + .../aio/operations/__init__.py | 2 + .../_confidential_ledger_operations.py | 83 ++ .../aio/operations/_ledger_operations.py | 481 ++++++----- .../aio/operations/_operations.py | 68 +- .../confidentialledger/models/__init__.py | 56 +- .../models/_confidential_ledger_enums.py | 30 +- .../mgmt/confidentialledger/models/_models.py | 513 ----------- .../confidentialledger/models/_models_py3.py | 325 +++++-- .../confidentialledger/operations/__init__.py | 2 + .../_confidential_ledger_operations.py | 127 +++ .../operations/_ledger_operations.py | 793 ++++++++++++------ .../operations/_operations.py | 108 ++- 24 files changed, 1626 insertions(+), 1348 deletions(-) create mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_patch.py create mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_vendor.py create mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_patch.py create mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_confidential_ledger_operations.py delete mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models.py create mode 100644 sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_confidential_ledger_operations.py diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/_meta.json b/sdk/confidentialledger/azure-mgmt-confidentialledger/_meta.json index 1554df85cb64..63bf26608b29 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/_meta.json +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "ca6f936885935225f04082a79b4ad9ff501779af", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "d193d5e14708bb5edbc6b485cc65184d865db901", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/confidentialledger/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "autorest_command": "autorest specification/confidentialledger/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/confidentialledger/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/__init__.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/__init__.py index 417dd90acc47..fc9615145dc7 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/__init__.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['ConfidentialLedger'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_confidential_ledger.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_confidential_ledger.py index a4254c40dd4d..dcde29236353 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_confidential_ledger.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_confidential_ledger.py @@ -6,79 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, 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 azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import ConfidentialLedgerConfiguration -from .operations import Operations -from .operations import LedgerOperations from . import models +from ._configuration import ConfidentialLedgerConfiguration +from .operations import ConfidentialLedgerOperationsMixin, LedgerOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class ConfidentialLedger(object): +class ConfidentialLedger(ConfidentialLedgerOperationsMixin): """Microsoft Azure Confidential Compute Ledger Control Plane REST API version 2020-12-01-preview. :ivar operations: Operations operations - :vartype operations: confidential_ledger.operations.Operations + :vartype operations: azure.mgmt.confidentialledger.operations.Operations :ivar ledger: LedgerOperations operations - :vartype ledger: confidential_ledger.operations.LedgerOperations + :vartype ledger: azure.mgmt.confidentialledger.operations.LedgerOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = ConfidentialLedgerConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ConfidentialLedgerConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.ledger = LedgerOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.ledger = LedgerOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_configuration.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_configuration.py index 72aabd01e1c3..79a2b51bd21b 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_configuration.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class ConfidentialLedgerConfiguration(Configuration): +class ConfidentialLedgerConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ConfidentialLedger. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class ConfidentialLedgerConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ConfidentialLedgerConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + 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(ConfidentialLedgerConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-confidentialledger/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_metadata.json b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_metadata.json index 79852935d4f4..47e44daa2c4d 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_metadata.json +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2020-12-01-preview", - "total_api_version_list": ["2020-12-01-preview"], + "chosen_version": "2022-05-13", + "total_api_version_list": ["2022-05-13"], "client": { "name": "ConfidentialLedger", "filename": "_confidential_ledger", "description": "Microsoft Azure Confidential Compute Ledger Control Plane REST API version 2020-12-01-preview.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConfidentialLedgerConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConfidentialLedgerConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConfidentialLedgerConfiguration\"], \"._operations_mixin\": [\"ConfidentialLedgerOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ConfidentialLedgerConfiguration\"], \"._operations_mixin\": [\"ConfidentialLedgerOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,14 +91,31 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", "ledger": "LedgerOperations" + }, + "operation_mixins": { + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "operations": { + "check_name_availability" : { + "sync": { + "signature": "def check_name_availability(\n self,\n name_availability_request, # type: \"_models.CheckNameAvailabilityRequest\"\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.CheckNameAvailabilityResponse\"\n", + "doc": "\"\"\"To check whether a resource name is available.\n\n:param name_availability_request: Name availability request payload.\n:type name_availability_request:\n ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckNameAvailabilityResponse, or the result of cls(response)\n:rtype: ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def check_name_availability(\n self,\n name_availability_request: \"_models.CheckNameAvailabilityRequest\",\n **kwargs: Any\n) -\u003e \"_models.CheckNameAvailabilityResponse\":\n", + "doc": "\"\"\"To check whether a resource name is available.\n\n:param name_availability_request: Name availability request payload.\n:type name_availability_request:\n ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CheckNameAvailabilityResponse, or the result of cls(response)\n:rtype: ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "name_availability_request" + } + } } } \ No newline at end of file diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_patch.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_vendor.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_version.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_version.py index e5754a47ce68..c47f66669f1b 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_version.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0" diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/__init__.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/__init__.py index 5dac9fbd6c0c..4a52e4af9dc4 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/__init__.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/__init__.py @@ -8,3 +8,8 @@ from ._confidential_ledger import ConfidentialLedger __all__ = ['ConfidentialLedger'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_confidential_ledger.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_confidential_ledger.py index 7a6c97ecc151..e86640390068 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_confidential_ledger.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_confidential_ledger.py @@ -6,75 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -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 azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import ConfidentialLedgerConfiguration -from .operations import Operations -from .operations import LedgerOperations from .. import models +from ._configuration import ConfidentialLedgerConfiguration +from .operations import ConfidentialLedgerOperationsMixin, LedgerOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class ConfidentialLedger(object): +class ConfidentialLedger(ConfidentialLedgerOperationsMixin): """Microsoft Azure Confidential Compute Ledger Control Plane REST API version 2020-12-01-preview. :ivar operations: Operations operations - :vartype operations: confidential_ledger.aio.operations.Operations + :vartype operations: azure.mgmt.confidentialledger.aio.operations.Operations :ivar ledger: LedgerOperations operations - :vartype ledger: confidential_ledger.aio.operations.LedgerOperations + :vartype ledger: azure.mgmt.confidentialledger.aio.operations.LedgerOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = ConfidentialLedgerConfiguration(credential, subscription_id, **kwargs) + self._config = ConfidentialLedgerConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.ledger = LedgerOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.ledger = LedgerOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_configuration.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_configuration.py index 2ee429fca1ab..003467f0d5b1 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_configuration.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ConfidentialLedgerConfiguration(Configuration): +class ConfidentialLedgerConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for ConfidentialLedger. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class ConfidentialLedgerConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(ConfidentialLedgerConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + 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(ConfidentialLedgerConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-12-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-confidentialledger/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_patch.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/__init__.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/__init__.py index 31a62ec935fe..16166aae0411 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/__init__.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/__init__.py @@ -7,9 +7,11 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._confidential_ledger_operations import ConfidentialLedgerOperationsMixin from ._ledger_operations import LedgerOperations __all__ = [ 'Operations', + 'ConfidentialLedgerOperationsMixin', 'LedgerOperations', ] diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_confidential_ledger_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_confidential_ledger_operations.py new file mode 100644 index 000000000000..774f46ade77e --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_confidential_ledger_operations.py @@ -0,0 +1,83 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._confidential_ledger_operations import build_check_name_availability_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfidentialLedgerOperationsMixin: + + @distributed_trace_async + async def check_name_availability( + self, + name_availability_request: "_models.CheckNameAvailabilityRequest", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResponse": + """To check whether a resource name is available. + + :param name_availability_request: Name availability request payload. + :type name_availability_request: + ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse, or the result of cls(response) + :rtype: ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/checkNameAvailability"} # type: ignore + diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_ledger_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_ledger_operations.py index 66023a322455..14a9a92e32f0 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_ledger_operations.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_ledger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,19 +6,22 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._ledger_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -28,7 +32,7 @@ class LedgerOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~confidential_ledger.models + :type models: ~azure.mgmt.confidentialledger.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -43,11 +47,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, ledger_name: str, - **kwargs + **kwargs: Any ) -> "_models.ConfidentialLedger": """Retrieves information about a Confidential Ledger resource. @@ -59,7 +64,7 @@ async def get( :type ledger_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfidentialLedger, or the result of cls(response) - :rtype: ~confidential_ledger.models.ConfidentialLedger + :rtype: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] @@ -67,33 +72,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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') + api_version = kwargs.pop('api_version', "2022-05-13") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfidentialLedger', pipeline_response) @@ -102,58 +104,58 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore - async def _delete_initial( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, ledger_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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') + api_version = kwargs.pop('api_version', "2022-05-13") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore - async def begin_delete( + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, ledger_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes a Confidential Ledger resource. @@ -165,14 +167,17 @@ async def begin_delete( :type ledger_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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -184,24 +189,18 @@ async def begin_delete( raw_result = await self._delete_initial( resource_group_name=resource_group_name, ledger_name=ledger_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -211,55 +210,50 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore async def _create_initial( self, resource_group_name: str, ledger_name: str, confidential_ledger: "_models.ConfidentialLedger", - **kwargs + **kwargs: Any ) -> Optional["_models.ConfidentialLedger"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfidentialLedger"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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['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(confidential_ledger, 'ConfidentialLedger') - 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) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(confidential_ledger, 'ConfidentialLedger') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -269,14 +263,17 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + @distributed_trace_async async def begin_create( self, resource_group_name: str, ledger_name: str, confidential_ledger: "_models.ConfidentialLedger", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ConfidentialLedger"]: """Creates a Confidential Ledger. @@ -287,17 +284,23 @@ async def begin_create( :param ledger_name: Name of the Confidential Ledger. :type ledger_name: str :param confidential_ledger: Confidential Ledger Create Request Body. - :type confidential_ledger: ~confidential_ledger.models.ConfidentialLedger + :type confidential_ledger: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ConfidentialLedger or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~confidential_ledger.models.ConfidentialLedger] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfidentialLedger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] lro_delay = kwargs.pop( @@ -310,27 +313,22 @@ async def begin_create( resource_group_name=resource_group_name, ledger_name=ledger_name, confidential_ledger=confidential_ledger, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfidentialLedger', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -340,55 +338,50 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore async def _update_initial( self, resource_group_name: str, ledger_name: str, confidential_ledger: "_models.ConfidentialLedger", - **kwargs + **kwargs: Any ) -> Optional["_models.ConfidentialLedger"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfidentialLedger"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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['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(confidential_ledger, 'ConfidentialLedger') - 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) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(confidential_ledger, 'ConfidentialLedger') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -398,14 +391,17 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + @distributed_trace_async async def begin_update( self, resource_group_name: str, ledger_name: str, confidential_ledger: "_models.ConfidentialLedger", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.ConfidentialLedger"]: """Update Confidential Ledger properties. @@ -416,17 +412,23 @@ async def begin_update( :param ledger_name: Name of the Confidential Ledger. :type ledger_name: str :param confidential_ledger: Confidential Ledger request body for Updating Ledger. - :type confidential_ledger: ~confidential_ledger.models.ConfidentialLedger + :type confidential_ledger: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :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: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ConfidentialLedger or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~confidential_ledger.models.ConfidentialLedger] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfidentialLedger or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] lro_delay = kwargs.pop( @@ -439,27 +441,22 @@ async def begin_update( resource_group_name=resource_group_name, ledger_name=ledger_name, confidential_ledger=confidential_ledger, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfidentialLedger', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -469,65 +466,70 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConfidentialLedgerList"]: - """Retrieves information about all Confidential Ledger resources under the given subscription and resource group. + """Retrieves information about all Confidential Ledger resources under the given subscription and + resource group. Retrieves the properties of all Confidential Ledgers. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param filter: The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public'. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfidentialLedgerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~confidential_ledger.models.ConfidentialLedgerList] + :return: An iterator like instance of either ConfidentialLedgerList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.confidentialledger.models.ConfidentialLedgerList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedgerList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), - } - url = self._client.format_url(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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfidentialLedgerList', pipeline_response) + deserialized = self._deserialize("ConfidentialLedgerList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -536,72 +538,80 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers"} # type: ignore + @distributed_trace def list_by_subscription( self, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConfidentialLedgerList"]: """Retrieves information about all Confidential Ledger resources under the given subscription. Retrieves the properties of all Confidential Ledgers. :param filter: The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public'. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfidentialLedgerList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~confidential_ledger.models.ConfidentialLedgerList] + :return: An iterator like instance of either ConfidentialLedgerList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.confidentialledger.models.ConfidentialLedgerList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedgerList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfidentialLedgerList', pipeline_response) + deserialized = self._deserialize("ConfidentialLedgerList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -610,17 +620,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/ledgers/'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/ledgers/"} # type: ignore diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_operations.py index 20504012bc76..697775bcaf02 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_operations.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -26,7 +29,7 @@ class Operations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~confidential_ledger.models + :type models: ~azure.mgmt.confidentialledger.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,48 +44,52 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ResourceProviderOperationList"]: """Retrieves a list of available API operations under this Resource Provider. Retrieves a list of available API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~confidential_ledger.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.confidentialledger.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -91,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ConfidentialLedger/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ConfidentialLedger/operations"} # type: ignore diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/__init__.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/__init__.py index 2eb64d313a39..2021842fec63 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/__init__.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/__init__.py @@ -6,40 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AADBasedSecurityPrincipal - from ._models_py3 import CertBasedSecurityPrincipal - from ._models_py3 import ConfidentialLedger - from ._models_py3 import ConfidentialLedgerList - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import LedgerProperties - from ._models_py3 import Location - from ._models_py3 import Resource - from ._models_py3 import ResourceProviderOperationDefinition - from ._models_py3 import ResourceProviderOperationDisplay - from ._models_py3 import ResourceProviderOperationList - from ._models_py3 import SystemData - from ._models_py3 import Tags -except (SyntaxError, ImportError): - from ._models import AADBasedSecurityPrincipal # type: ignore - from ._models import CertBasedSecurityPrincipal # type: ignore - from ._models import ConfidentialLedger # type: ignore - from ._models import ConfidentialLedgerList # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LedgerProperties # type: ignore - from ._models import Location # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceProviderOperationDefinition # type: ignore - from ._models import ResourceProviderOperationDisplay # type: ignore - from ._models import ResourceProviderOperationList # type: ignore - from ._models import SystemData # type: ignore - from ._models import Tags # type: ignore +from ._models_py3 import AADBasedSecurityPrincipal +from ._models_py3 import CertBasedSecurityPrincipal +from ._models_py3 import CheckNameAvailabilityRequest +from ._models_py3 import CheckNameAvailabilityResponse +from ._models_py3 import ConfidentialLedger +from ._models_py3 import ConfidentialLedgerList +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import LedgerProperties +from ._models_py3 import Resource +from ._models_py3 import ResourceLocation +from ._models_py3 import ResourceProviderOperationDefinition +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import SystemData +from ._models_py3 import Tags + from ._confidential_ledger_enums import ( + CheckNameAvailabilityReason, CreatedByType, LedgerRoleName, LedgerType, @@ -49,19 +36,22 @@ __all__ = [ 'AADBasedSecurityPrincipal', 'CertBasedSecurityPrincipal', + 'CheckNameAvailabilityRequest', + 'CheckNameAvailabilityResponse', 'ConfidentialLedger', 'ConfidentialLedgerList', 'ErrorAdditionalInfo', 'ErrorDetail', 'ErrorResponse', 'LedgerProperties', - 'Location', 'Resource', + 'ResourceLocation', 'ResourceProviderOperationDefinition', 'ResourceProviderOperationDisplay', 'ResourceProviderOperationList', 'SystemData', 'Tags', + 'CheckNameAvailabilityReason', 'CreatedByType', 'LedgerRoleName', 'LedgerType', diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_confidential_ledger_enums.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_confidential_ledger_enums.py index 307c2fe92581..67cc9c556fa5 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_confidential_ledger_enums.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_confidential_ledger_enums.py @@ -6,27 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) +class CheckNameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The reason why the given name is not available. + """ + INVALID = "Invalid" + ALREADY_EXISTS = "AlreadyExists" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +27,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LedgerRoleName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LedgerRoleName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """LedgerRole associated with the Security Principal of Ledger """ @@ -43,7 +35,7 @@ class LedgerRoleName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONTRIBUTOR = "Contributor" ADMINISTRATOR = "Administrator" -class LedgerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LedgerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the ledger. Private means transaction data is encrypted. """ @@ -51,7 +43,7 @@ class LedgerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PUBLIC = "Public" PRIVATE = "Private" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Object representing ProvisioningState for Confidential Ledger. """ diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models.py deleted file mode 100644 index ac3f9958c345..000000000000 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models.py +++ /dev/null @@ -1,513 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AADBasedSecurityPrincipal(msrest.serialization.Model): - """AAD based security principal with associated Ledger RoleName. - - :param principal_id: UUID/GUID based Principal Id of the Security Principal. - :type principal_id: str - :param tenant_id: UUID/GUID based Tenant Id of the Security Principal. - :type tenant_id: str - :param ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible - values include: "Reader", "Contributor", "Administrator". - :type ledger_role_name: str or ~confidential_ledger.models.LedgerRoleName - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'ledger_role_name': {'key': 'ledgerRoleName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AADBasedSecurityPrincipal, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.ledger_role_name = kwargs.get('ledger_role_name', None) - - -class CertBasedSecurityPrincipal(msrest.serialization.Model): - """Cert based security principal with Ledger RoleName. - - :param cert: Base64 encoded public key of the user cert (.pem or .cer). - :type cert: str - :param ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible - values include: "Reader", "Contributor", "Administrator". - :type ledger_role_name: str or ~confidential_ledger.models.LedgerRoleName - """ - - _attribute_map = { - 'cert': {'key': 'cert', 'type': 'str'}, - 'ledger_role_name': {'key': 'ledgerRoleName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertBasedSecurityPrincipal, self).__init__(**kwargs) - self.cert = kwargs.get('cert', None) - self.ledger_role_name = kwargs.get('ledger_role_name', None) - - -class Tags(msrest.serialization.Model): - """Tags for Confidential Ledger Resource. - - :param tags: A set of tags. Additional tags for Confidential Ledger. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Tags, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class Location(msrest.serialization.Model): - """Location of the ARM Resource. - - :param location: The Azure location where the Confidential Ledger is running. - :type location: str - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Location, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - - -class Resource(msrest.serialization.Model): - """An Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the Resource. - :vartype name: str - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~confidential_ledger.models.SystemData - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.name = None - self.id = None - self.type = None - self.system_data = None - - -class ConfidentialLedger(Resource, Location, Tags): - """Confidential Ledger. Contains the properties of Confidential Ledger Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param tags: A set of tags. Additional tags for Confidential Ledger. - :type tags: dict[str, str] - :param location: The Azure location where the Confidential Ledger is running. - :type location: str - :ivar name: Name of the Resource. - :vartype name: str - :ivar id: Fully qualified resource Id for the resource. - :vartype id: str - :ivar type: The type of the resource. - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~confidential_ledger.models.SystemData - :param properties: Properties of Confidential Ledger Resource. - :type properties: ~confidential_ledger.models.LedgerProperties - """ - - _validation = { - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'LedgerProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfidentialLedger, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.system_data = None - self.properties = kwargs.get('properties', None) - self.location = kwargs.get('location', None) - self.name = None - self.id = None - self.type = None - self.system_data = None - self.properties = kwargs.get('properties', None) - - -class ConfidentialLedgerList(msrest.serialization.Model): - """Object that includes an array of Confidential Ledgers and a possible link for next set. - - :param value: List of Confidential Ledgers. - :type value: list[~confidential_ledger.models.ConfidentialLedger] - :param next_link: The URL the client should use to fetch the next page (per server side - paging). - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfidentialLedger]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfidentialLedgerList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: object - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~confidential_ledger.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~confidential_ledger.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~confidential_ledger.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class LedgerProperties(msrest.serialization.Model): - """Additional Confidential Ledger properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar ledger_name: Unique name for the Confidential Ledger. - :vartype ledger_name: str - :ivar ledger_uri: Endpoint for calling Ledger Service. - :vartype ledger_uri: str - :ivar identity_service_uri: Endpoint for accessing network identity. - :vartype identity_service_uri: str - :ivar ledger_internal_namespace: Internal namespace for the Ledger. - :vartype ledger_internal_namespace: str - :param ledger_storage_account: Name of the Blob Storage Account for saving ledger files. - :type ledger_storage_account: str - :param ledger_type: Type of Confidential Ledger. Possible values include: "Unknown", "Public", - "Private". - :type ledger_type: str or ~confidential_ledger.models.LedgerType - :ivar provisioning_state: Provisioning state of Ledger Resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Creating", "Deleting", "Updating". - :vartype provisioning_state: str or ~confidential_ledger.models.ProvisioningState - :param aad_based_security_principals: Array of all AAD based Security Principals. - :type aad_based_security_principals: - list[~confidential_ledger.models.AADBasedSecurityPrincipal] - :param cert_based_security_principals: Array of all cert based Security Principals. - :type cert_based_security_principals: - list[~confidential_ledger.models.CertBasedSecurityPrincipal] - """ - - _validation = { - 'ledger_name': {'readonly': True}, - 'ledger_uri': {'readonly': True}, - 'identity_service_uri': {'readonly': True}, - 'ledger_internal_namespace': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'ledger_name': {'key': 'ledgerName', 'type': 'str'}, - 'ledger_uri': {'key': 'ledgerUri', 'type': 'str'}, - 'identity_service_uri': {'key': 'identityServiceUri', 'type': 'str'}, - 'ledger_internal_namespace': {'key': 'ledgerInternalNamespace', 'type': 'str'}, - 'ledger_storage_account': {'key': 'ledgerStorageAccount', 'type': 'str'}, - 'ledger_type': {'key': 'ledgerType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'aad_based_security_principals': {'key': 'aadBasedSecurityPrincipals', 'type': '[AADBasedSecurityPrincipal]'}, - 'cert_based_security_principals': {'key': 'certBasedSecurityPrincipals', 'type': '[CertBasedSecurityPrincipal]'}, - } - - def __init__( - self, - **kwargs - ): - super(LedgerProperties, self).__init__(**kwargs) - self.ledger_name = None - self.ledger_uri = None - self.identity_service_uri = None - self.ledger_internal_namespace = None - self.ledger_storage_account = kwargs.get('ledger_storage_account', None) - self.ledger_type = kwargs.get('ledger_type', None) - self.provisioning_state = None - self.aad_based_security_principals = kwargs.get('aad_based_security_principals', None) - self.cert_based_security_principals = kwargs.get('cert_based_security_principals', None) - - -class ResourceProviderOperationDefinition(msrest.serialization.Model): - """Describes the Resource Provider Operation. - - :param name: Resource provider operation name. - :type name: str - :param is_data_action: Indicates whether the operation is data action or not. - :type is_data_action: bool - :param display: Details about the operations. - :type display: ~confidential_ledger.models.ResourceProviderOperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationDefinition, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - - -class ResourceProviderOperationDisplay(msrest.serialization.Model): - """Describes the properties of the Operation. - - :param provider: Name of the resource provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the resource provider operation. - :type operation: str - :param description: Description of the resource provider operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class ResourceProviderOperationList(msrest.serialization.Model): - """List containing this Resource Provider's available operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Resource provider operations list. - :vartype value: list[~confidential_ledger.models.ResourceProviderOperationDefinition] - :ivar next_link: The URI that can be used to request the next page for list of Azure - operations. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~confidential_ledger.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~confidential_ledger.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models_py3.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models_py3.py index 5b34efc88dae..83fc4a88ed5a 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models_py3.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/models/_models_py3.py @@ -18,13 +18,13 @@ class AADBasedSecurityPrincipal(msrest.serialization.Model): """AAD based security principal with associated Ledger RoleName. - :param principal_id: UUID/GUID based Principal Id of the Security Principal. - :type principal_id: str - :param tenant_id: UUID/GUID based Tenant Id of the Security Principal. - :type tenant_id: str - :param ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible + :ivar principal_id: UUID/GUID based Principal Id of the Security Principal. + :vartype principal_id: str + :ivar tenant_id: UUID/GUID based Tenant Id of the Security Principal. + :vartype tenant_id: str + :ivar ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible values include: "Reader", "Contributor", "Administrator". - :type ledger_role_name: str or ~confidential_ledger.models.LedgerRoleName + :vartype ledger_role_name: str or ~azure.mgmt.confidentialledger.models.LedgerRoleName """ _attribute_map = { @@ -41,6 +41,15 @@ def __init__( ledger_role_name: Optional[Union[str, "LedgerRoleName"]] = None, **kwargs ): + """ + :keyword principal_id: UUID/GUID based Principal Id of the Security Principal. + :paramtype principal_id: str + :keyword tenant_id: UUID/GUID based Tenant Id of the Security Principal. + :paramtype tenant_id: str + :keyword ledger_role_name: LedgerRole associated with the Security Principal of Ledger. + Possible values include: "Reader", "Contributor", "Administrator". + :paramtype ledger_role_name: str or ~azure.mgmt.confidentialledger.models.LedgerRoleName + """ super(AADBasedSecurityPrincipal, self).__init__(**kwargs) self.principal_id = principal_id self.tenant_id = tenant_id @@ -50,11 +59,11 @@ def __init__( class CertBasedSecurityPrincipal(msrest.serialization.Model): """Cert based security principal with Ledger RoleName. - :param cert: Base64 encoded public key of the user cert (.pem or .cer). - :type cert: str - :param ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible + :ivar cert: Public key of the user cert (.pem or .cer). + :vartype cert: str + :ivar ledger_role_name: LedgerRole associated with the Security Principal of Ledger. Possible values include: "Reader", "Contributor", "Administrator". - :type ledger_role_name: str or ~confidential_ledger.models.LedgerRoleName + :vartype ledger_role_name: str or ~azure.mgmt.confidentialledger.models.LedgerRoleName """ _attribute_map = { @@ -69,16 +78,96 @@ def __init__( ledger_role_name: Optional[Union[str, "LedgerRoleName"]] = None, **kwargs ): + """ + :keyword cert: Public key of the user cert (.pem or .cer). + :paramtype cert: str + :keyword ledger_role_name: LedgerRole associated with the Security Principal of Ledger. + Possible values include: "Reader", "Contributor", "Administrator". + :paramtype ledger_role_name: str or ~azure.mgmt.confidentialledger.models.LedgerRoleName + """ super(CertBasedSecurityPrincipal, self).__init__(**kwargs) self.cert = cert self.ledger_role_name = ledger_role_name +class CheckNameAvailabilityRequest(msrest.serialization.Model): + """The check availability request body. + + :ivar name: The name of the resource for which availability needs to be checked. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of the resource for which availability needs to be checked. + :paramtype name: str + :keyword type: The resource type. + :paramtype type: str + """ + super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + self.name = name + self.type = type + + +class CheckNameAvailabilityResponse(msrest.serialization.Model): + """The check availability result. + + :ivar name_available: Indicates if the resource name is available. + :vartype name_available: bool + :ivar reason: The reason why the given name is not available. Possible values include: + "Invalid", "AlreadyExists". + :vartype reason: str or ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityReason + :ivar message: Detailed reason why the given name is available. + :vartype message: str + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[Union[str, "CheckNameAvailabilityReason"]] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: Indicates if the resource name is available. + :paramtype name_available: bool + :keyword reason: The reason why the given name is not available. Possible values include: + "Invalid", "AlreadyExists". + :paramtype reason: str or ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityReason + :keyword message: Detailed reason why the given name is available. + :paramtype message: str + """ + super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = message + + class Tags(msrest.serialization.Model): """Tags for Confidential Ledger Resource. - :param tags: A set of tags. Additional tags for Confidential Ledger. - :type tags: dict[str, str] + :ivar tags: A set of tags. Additional tags for Confidential Ledger. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -91,15 +180,19 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Additional tags for Confidential Ledger. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags -class Location(msrest.serialization.Model): +class ResourceLocation(msrest.serialization.Model): """Location of the ARM Resource. - :param location: The Azure location where the Confidential Ledger is running. - :type location: str + :ivar location: The Azure location where the Confidential Ledger is running. + :vartype location: str """ _attribute_map = { @@ -112,7 +205,11 @@ def __init__( location: Optional[str] = None, **kwargs ): - super(Location, self).__init__(**kwargs) + """ + :keyword location: The Azure location where the Confidential Ledger is running. + :paramtype location: str + """ + super(ResourceLocation, self).__init__(**kwargs) self.location = location @@ -128,7 +225,7 @@ class Resource(msrest.serialization.Model): :ivar type: The type of the resource. :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~confidential_ledger.models.SystemData + :vartype system_data: ~azure.mgmt.confidentialledger.models.SystemData """ _validation = { @@ -149,6 +246,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.name = None self.id = None @@ -156,15 +255,15 @@ def __init__( self.system_data = None -class ConfidentialLedger(Resource, Location, Tags): +class ConfidentialLedger(Resource, ResourceLocation, Tags): """Confidential Ledger. Contains the properties of Confidential Ledger Resource. Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Additional tags for Confidential Ledger. - :type tags: dict[str, str] - :param location: The Azure location where the Confidential Ledger is running. - :type location: str + :ivar tags: A set of tags. Additional tags for Confidential Ledger. + :vartype tags: dict[str, str] + :ivar location: The Azure location where the Confidential Ledger is running. + :vartype location: str :ivar name: Name of the Resource. :vartype name: str :ivar id: Fully qualified resource Id for the resource. @@ -172,9 +271,9 @@ class ConfidentialLedger(Resource, Location, Tags): :ivar type: The type of the resource. :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~confidential_ledger.models.SystemData - :param properties: Properties of Confidential Ledger Resource. - :type properties: ~confidential_ledger.models.LedgerProperties + :vartype system_data: ~azure.mgmt.confidentialledger.models.SystemData + :ivar properties: Properties of Confidential Ledger Resource. + :vartype properties: ~azure.mgmt.confidentialledger.models.LedgerProperties """ _validation = { @@ -202,32 +301,31 @@ def __init__( properties: Optional["LedgerProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Additional tags for Confidential Ledger. + :paramtype tags: dict[str, str] + :keyword location: The Azure location where the Confidential Ledger is running. + :paramtype location: str + :keyword properties: Properties of Confidential Ledger Resource. + :paramtype properties: ~azure.mgmt.confidentialledger.models.LedgerProperties + """ super(ConfidentialLedger, self).__init__(location=location, tags=tags, **kwargs) self.tags = tags self.location = location self.properties = properties - self.tags = tags self.name = None self.id = None self.type = None self.system_data = None - self.properties = properties - self.location = location - self.name = None - self.id = None - self.type = None - self.system_data = None - self.properties = properties class ConfidentialLedgerList(msrest.serialization.Model): """Object that includes an array of Confidential Ledgers and a possible link for next set. - :param value: List of Confidential Ledgers. - :type value: list[~confidential_ledger.models.ConfidentialLedger] - :param next_link: The URL the client should use to fetch the next page (per server side - paging). - :type next_link: str + :ivar value: List of Confidential Ledgers. + :vartype value: list[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :ivar next_link: The URL the client should use to fetch the next page (per server side paging). + :vartype next_link: str """ _attribute_map = { @@ -242,6 +340,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of Confidential Ledgers. + :paramtype value: list[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :keyword next_link: The URL the client should use to fetch the next page (per server side + paging). + :paramtype next_link: str + """ super(ConfidentialLedgerList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -255,7 +360,7 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: object + :vartype info: any """ _validation = { @@ -272,6 +377,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -289,9 +396,9 @@ class ErrorDetail(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~confidential_ledger.models.ErrorDetail] + :vartype details: list[~azure.mgmt.confidentialledger.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: list[~confidential_ledger.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.confidentialledger.models.ErrorAdditionalInfo] """ _validation = { @@ -314,6 +421,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -325,8 +434,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~confidential_ledger.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.confidentialledger.models.ErrorDetail """ _attribute_map = { @@ -339,6 +448,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.confidentialledger.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -356,20 +469,18 @@ class LedgerProperties(msrest.serialization.Model): :vartype identity_service_uri: str :ivar ledger_internal_namespace: Internal namespace for the Ledger. :vartype ledger_internal_namespace: str - :param ledger_storage_account: Name of the Blob Storage Account for saving ledger files. - :type ledger_storage_account: str - :param ledger_type: Type of Confidential Ledger. Possible values include: "Unknown", "Public", + :ivar ledger_type: Type of Confidential Ledger. Possible values include: "Unknown", "Public", "Private". - :type ledger_type: str or ~confidential_ledger.models.LedgerType + :vartype ledger_type: str or ~azure.mgmt.confidentialledger.models.LedgerType :ivar provisioning_state: Provisioning state of Ledger Resource. Possible values include: "Unknown", "Succeeded", "Failed", "Canceled", "Creating", "Deleting", "Updating". - :vartype provisioning_state: str or ~confidential_ledger.models.ProvisioningState - :param aad_based_security_principals: Array of all AAD based Security Principals. - :type aad_based_security_principals: - list[~confidential_ledger.models.AADBasedSecurityPrincipal] - :param cert_based_security_principals: Array of all cert based Security Principals. - :type cert_based_security_principals: - list[~confidential_ledger.models.CertBasedSecurityPrincipal] + :vartype provisioning_state: str or ~azure.mgmt.confidentialledger.models.ProvisioningState + :ivar aad_based_security_principals: Array of all AAD based Security Principals. + :vartype aad_based_security_principals: + list[~azure.mgmt.confidentialledger.models.AADBasedSecurityPrincipal] + :ivar cert_based_security_principals: Array of all cert based Security Principals. + :vartype cert_based_security_principals: + list[~azure.mgmt.confidentialledger.models.CertBasedSecurityPrincipal] """ _validation = { @@ -385,7 +496,6 @@ class LedgerProperties(msrest.serialization.Model): 'ledger_uri': {'key': 'ledgerUri', 'type': 'str'}, 'identity_service_uri': {'key': 'identityServiceUri', 'type': 'str'}, 'ledger_internal_namespace': {'key': 'ledgerInternalNamespace', 'type': 'str'}, - 'ledger_storage_account': {'key': 'ledgerStorageAccount', 'type': 'str'}, 'ledger_type': {'key': 'ledgerType', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'aad_based_security_principals': {'key': 'aadBasedSecurityPrincipals', 'type': '[AADBasedSecurityPrincipal]'}, @@ -395,18 +505,27 @@ class LedgerProperties(msrest.serialization.Model): def __init__( self, *, - ledger_storage_account: Optional[str] = None, ledger_type: Optional[Union[str, "LedgerType"]] = None, aad_based_security_principals: Optional[List["AADBasedSecurityPrincipal"]] = None, cert_based_security_principals: Optional[List["CertBasedSecurityPrincipal"]] = None, **kwargs ): + """ + :keyword ledger_type: Type of Confidential Ledger. Possible values include: "Unknown", + "Public", "Private". + :paramtype ledger_type: str or ~azure.mgmt.confidentialledger.models.LedgerType + :keyword aad_based_security_principals: Array of all AAD based Security Principals. + :paramtype aad_based_security_principals: + list[~azure.mgmt.confidentialledger.models.AADBasedSecurityPrincipal] + :keyword cert_based_security_principals: Array of all cert based Security Principals. + :paramtype cert_based_security_principals: + list[~azure.mgmt.confidentialledger.models.CertBasedSecurityPrincipal] + """ super(LedgerProperties, self).__init__(**kwargs) self.ledger_name = None self.ledger_uri = None self.identity_service_uri = None self.ledger_internal_namespace = None - self.ledger_storage_account = ledger_storage_account self.ledger_type = ledger_type self.provisioning_state = None self.aad_based_security_principals = aad_based_security_principals @@ -416,12 +535,12 @@ def __init__( class ResourceProviderOperationDefinition(msrest.serialization.Model): """Describes the Resource Provider Operation. - :param name: Resource provider operation name. - :type name: str - :param is_data_action: Indicates whether the operation is data action or not. - :type is_data_action: bool - :param display: Details about the operations. - :type display: ~confidential_ledger.models.ResourceProviderOperationDisplay + :ivar name: Resource provider operation name. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is data action or not. + :vartype is_data_action: bool + :ivar display: Details about the operations. + :vartype display: ~azure.mgmt.confidentialledger.models.ResourceProviderOperationDisplay """ _attribute_map = { @@ -438,6 +557,14 @@ def __init__( display: Optional["ResourceProviderOperationDisplay"] = None, **kwargs ): + """ + :keyword name: Resource provider operation name. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is data action or not. + :paramtype is_data_action: bool + :keyword display: Details about the operations. + :paramtype display: ~azure.mgmt.confidentialledger.models.ResourceProviderOperationDisplay + """ super(ResourceProviderOperationDefinition, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -447,14 +574,14 @@ def __init__( class ResourceProviderOperationDisplay(msrest.serialization.Model): """Describes the properties of the Operation. - :param provider: Name of the resource provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the resource provider operation. - :type operation: str - :param description: Description of the resource provider operation. - :type description: str + :ivar provider: Name of the resource provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the resource provider operation. + :vartype operation: str + :ivar description: Description of the resource provider operation. + :vartype description: str """ _attribute_map = { @@ -473,6 +600,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Name of the resource provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the resource provider operation. + :paramtype operation: str + :keyword description: Description of the resource provider operation. + :paramtype description: str + """ super(ResourceProviderOperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -486,7 +623,7 @@ class ResourceProviderOperationList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Resource provider operations list. - :vartype value: list[~confidential_ledger.models.ResourceProviderOperationDefinition] + :vartype value: list[~azure.mgmt.confidentialledger.models.ResourceProviderOperationDefinition] :ivar next_link: The URI that can be used to request the next page for list of Azure operations. :vartype next_link: str @@ -506,6 +643,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceProviderOperationList, self).__init__(**kwargs) self.value = None self.next_link = None @@ -514,20 +653,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~confidential_ledger.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.confidentialledger.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~confidential_ledger.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.confidentialledger.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -550,6 +689,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.confidentialledger.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.confidentialledger.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/__init__.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/__init__.py index 31a62ec935fe..16166aae0411 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/__init__.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/__init__.py @@ -7,9 +7,11 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._confidential_ledger_operations import ConfidentialLedgerOperationsMixin from ._ledger_operations import LedgerOperations __all__ = [ 'Operations', + 'ConfidentialLedgerOperationsMixin', 'LedgerOperations', ] diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_confidential_ledger_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_confidential_ledger_operations.py new file mode 100644 index 000000000000..9c0403a99afe --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_confidential_ledger_operations.py @@ -0,0 +1,127 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/checkNameAvailability") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class ConfidentialLedgerOperationsMixin(object): + + @distributed_trace + def check_name_availability( + self, + name_availability_request: "_models.CheckNameAvailabilityRequest", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResponse": + """To check whether a resource name is available. + + :param name_availability_request: Name availability request payload. + :type name_availability_request: + ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse, or the result of cls(response) + :rtype: ~azure.mgmt.confidentialledger.models.CheckNameAvailabilityResponse + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(name_availability_request, 'CheckNameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/checkNameAvailability"} # type: ignore + diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_ledger_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_ledger_operations.py index 69f22dd52a25..983f8f075c68 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_ledger_operations.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_ledger_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,25 +6,261 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + ledger_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), + "ledgerName": _SERIALIZER.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + ledger_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), + "ledgerName": _SERIALIZER.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + ledger_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), + "ledgerName": _SERIALIZER.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + ledger_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), + "ledgerName": _SERIALIZER.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/ledgers/") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class LedgerOperations(object): """LedgerOperations operations. @@ -32,7 +269,7 @@ class LedgerOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~confidential_ledger.models + :type models: ~azure.mgmt.confidentialledger.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -47,13 +284,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - ledger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConfidentialLedger" + resource_group_name: str, + ledger_name: str, + **kwargs: Any + ) -> "_models.ConfidentialLedger": """Retrieves information about a Confidential Ledger resource. Retrieves the properties of a Confidential Ledger. @@ -64,7 +301,7 @@ def get( :type ledger_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ConfidentialLedger, or the result of cls(response) - :rtype: ~confidential_ledger.models.ConfidentialLedger + :rtype: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] @@ -72,33 +309,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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') + api_version = kwargs.pop('api_version', "2022-05-13") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfidentialLedger', pipeline_response) @@ -107,61 +341,59 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore - def _delete_initial( + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - ledger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + ledger_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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') + api_version = kwargs.pop('api_version', "2022-05-13") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore - def begin_delete( + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - ledger_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + ledger_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a Confidential Ledger resource. Deletes an existing Confidential Ledger. @@ -172,14 +404,17 @@ def begin_delete( :type ledger_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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :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: + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( @@ -191,24 +426,18 @@ def begin_delete( raw_result = self._delete_initial( resource_group_name=resource_group_name, ledger_name=ledger_name, + api_version=api_version, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -218,56 +447,50 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore def _create_initial( self, - resource_group_name, # type: str - ledger_name, # type: str - confidential_ledger, # type: "_models.ConfidentialLedger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ConfidentialLedger"] + resource_group_name: str, + ledger_name: str, + confidential_ledger: "_models.ConfidentialLedger", + **kwargs: Any + ) -> Optional["_models.ConfidentialLedger"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfidentialLedger"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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['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(confidential_ledger, 'ConfidentialLedger') - 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) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(confidential_ledger, 'ConfidentialLedger') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -277,16 +500,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - ledger_name, # type: str - confidential_ledger, # type: "_models.ConfidentialLedger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ConfidentialLedger"] + resource_group_name: str, + ledger_name: str, + confidential_ledger: "_models.ConfidentialLedger", + **kwargs: Any + ) -> LROPoller["_models.ConfidentialLedger"]: """Creates a Confidential Ledger. Creates a Confidential Ledger with the specified ledger parameters. @@ -296,17 +521,22 @@ def begin_create( :param ledger_name: Name of the Confidential Ledger. :type ledger_name: str :param confidential_ledger: Confidential Ledger Create Request Body. - :type confidential_ledger: ~confidential_ledger.models.ConfidentialLedger + :type confidential_ledger: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ConfidentialLedger or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~confidential_ledger.models.ConfidentialLedger] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfidentialLedger or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] lro_delay = kwargs.pop( @@ -319,27 +549,22 @@ def begin_create( resource_group_name=resource_group_name, ledger_name=ledger_name, confidential_ledger=confidential_ledger, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfidentialLedger', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -349,56 +574,50 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore def _update_initial( self, - resource_group_name, # type: str - ledger_name, # type: str - confidential_ledger, # type: "_models.ConfidentialLedger" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ConfidentialLedger"] + resource_group_name: str, + ledger_name: str, + confidential_ledger: "_models.ConfidentialLedger", + **kwargs: Any + ) -> Optional["_models.ConfidentialLedger"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfidentialLedger"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[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['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(confidential_ledger, 'ConfidentialLedger') - 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) + + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(confidential_ledger, 'ConfidentialLedger') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + ledger_name=ledger_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -408,16 +627,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - ledger_name, # type: str - confidential_ledger, # type: "_models.ConfidentialLedger" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ConfidentialLedger"] + resource_group_name: str, + ledger_name: str, + confidential_ledger: "_models.ConfidentialLedger", + **kwargs: Any + ) -> LROPoller["_models.ConfidentialLedger"]: """Update Confidential Ledger properties. Updates properties of Confidential Ledger. @@ -427,17 +648,22 @@ def begin_update( :param ledger_name: Name of the Confidential Ledger. :type ledger_name: str :param confidential_ledger: Confidential Ledger request body for Updating Ledger. - :type confidential_ledger: ~confidential_ledger.models.ConfidentialLedger + :type confidential_ledger: ~azure.mgmt.confidentialledger.models.ConfidentialLedger :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: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ConfidentialLedger or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~confidential_ledger.models.ConfidentialLedger] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfidentialLedger or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.confidentialledger.models.ConfidentialLedger] + :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedger"] lro_delay = kwargs.pop( @@ -450,27 +676,22 @@ def begin_update( resource_group_name=resource_group_name, ledger_name=ledger_name, confidential_ledger=confidential_ledger, + api_version=api_version, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfidentialLedger', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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', max_length=90, min_length=3), - 'ledgerName': self._serialize.url("ledger_name", ledger_name, 'str', pattern=r'^[a-zA-Z0-9]'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -480,66 +701,70 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers/{ledgerName}"} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConfidentialLedgerList"] - """Retrieves information about all Confidential Ledger resources under the given subscription and resource group. + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ConfidentialLedgerList"]: + """Retrieves information about all Confidential Ledger resources under the given subscription and + resource group. Retrieves the properties of all Confidential Ledgers. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param filter: The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public'. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfidentialLedgerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~confidential_ledger.models.ConfidentialLedgerList] + :return: An iterator like instance of either ConfidentialLedgerList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.confidentialledger.models.ConfidentialLedgerList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedgerList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=3), - } - url = self._client.format_url(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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfidentialLedgerList', pipeline_response) + deserialized = self._deserialize("ConfidentialLedgerList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -548,73 +773,80 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConfidentialLedger/ledgers"} # type: ignore + @distributed_trace def list_by_subscription( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ConfidentialLedgerList"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ConfidentialLedgerList"]: """Retrieves information about all Confidential Ledger resources under the given subscription. Retrieves the properties of all Confidential Ledgers. :param filter: The filter to apply on the list operation. eg. $filter=ledgerType eq 'Public'. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfidentialLedgerList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~confidential_ledger.models.ConfidentialLedgerList] + :return: An iterator like instance of either ConfidentialLedgerList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.confidentialledger.models.ConfidentialLedgerList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfidentialLedgerList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfidentialLedgerList', pipeline_response) + deserialized = self._deserialize("ConfidentialLedgerList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -623,17 +855,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/ledgers/'} # type: ignore + list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/ledgers/"} # type: ignore diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_operations.py b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_operations.py index 13d727092709..a0ec80cd4507 100644 --- a/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_operations.py +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/azure/mgmt/confidentialledger/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ConfidentialLedger/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -30,7 +58,7 @@ class Operations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~confidential_ledger.models + :type models: ~azure.mgmt.confidentialledger.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,49 +73,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceProviderOperationList"] + **kwargs: Any + ) -> Iterable["_models.ResourceProviderOperationList"]: """Retrieves a list of available API operations under this Resource Provider. Retrieves a list of available API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~confidential_ledger.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.confidentialledger.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2022-05-13") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-12-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 = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -96,17 +127,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.ConfidentialLedger/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.ConfidentialLedger/operations"} # type: ignore