diff --git a/sdk/blockchain/azure-mgmt-blockchain/CHANGELOG.md b/sdk/blockchain/azure-mgmt-blockchain/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/blockchain/azure-mgmt-blockchain/LICENSE b/sdk/blockchain/azure-mgmt-blockchain/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +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. diff --git a/sdk/blockchain/azure-mgmt-blockchain/MANIFEST.in b/sdk/blockchain/azure-mgmt-blockchain/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/MANIFEST.in @@ -0,0 +1,6 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE diff --git a/sdk/blockchain/azure-mgmt-blockchain/README.md b/sdk/blockchain/azure-mgmt-blockchain/README.md new file mode 100644 index 000000000000..c55865fea792 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/README.md @@ -0,0 +1,30 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 3.7+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-blockchain%2FREADME.png) diff --git a/sdk/blockchain/azure-mgmt-blockchain/_meta.json b/sdk/blockchain/azure-mgmt-blockchain/_meta.json new file mode 100644 index 000000000000..1df720ac10a6 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "89c3f105dc2811a1857912140106c36d14ee68f0", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/blockchain/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/blockchain/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/__init__.py new file mode 100644 index 000000000000..c0febd774957 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/__init__.py @@ -0,0 +1,18 @@ +# 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 ._blockchain_management_client import BlockchainManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['BlockchainManagementClient'] + +# `._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/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_blockchain_management_client.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_blockchain_management_client.py new file mode 100644 index 000000000000..46f8184fe3f2 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_blockchain_management_client.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import BlockchainManagementClientConfiguration +from .operations import BlockchainMemberOperationResultsOperations, BlockchainMembersOperations, LocationsOperations, Operations, SkusOperations, TransactionNodesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class BlockchainManagementClient: + """REST API for Azure Blockchain Service. + + :ivar blockchain_members: BlockchainMembersOperations operations + :vartype blockchain_members: + blockchain_management_client.operations.BlockchainMembersOperations + :ivar blockchain_member_operation_results: BlockchainMemberOperationResultsOperations + operations + :vartype blockchain_member_operation_results: + blockchain_management_client.operations.BlockchainMemberOperationResultsOperations + :ivar locations: LocationsOperations operations + :vartype locations: blockchain_management_client.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: blockchain_management_client.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: blockchain_management_client.operations.SkusOperations + :ivar transaction_nodes: TransactionNodesOperations operations + :vartype transaction_nodes: blockchain_management_client.operations.TransactionNodesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets the subscription Id which uniquely identifies the Microsoft Azure + subscription. The subscription ID is part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BlockchainManagementClientConfiguration(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.blockchain_members = BlockchainMembersOperations(self._client, self._config, self._serialize, self._deserialize) + self.blockchain_member_operation_results = BlockchainMemberOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.transaction_nodes = TransactionNodesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> 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.rest.HttpResponse + """ + + 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 + self._client.close() + + def __enter__(self): + # type: () -> BlockchainManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_configuration.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_configuration.py new file mode 100644 index 000000000000..42e0e3a70548 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class BlockchainManagementClientConfiguration(Configuration): + """Configuration for BlockchainManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(BlockchainManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-06-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-blockchain/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_metadata.json b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_metadata.json new file mode 100644 index 000000000000..31523d1fb5f2 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2018-06-01-preview", + "total_api_version_list": ["2018-06-01-preview"], + "client": { + "name": "BlockchainManagementClient", + "filename": "_blockchain_management_client", + "description": "REST API for Azure Blockchain Service.", + "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\": [\"BlockchainManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BlockchainManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "blockchain_members": "BlockchainMembersOperations", + "blockchain_member_operation_results": "BlockchainMemberOperationResultsOperations", + "locations": "LocationsOperations", + "operations": "Operations", + "skus": "SkusOperations", + "transaction_nodes": "TransactionNodesOperations" + } +} \ No newline at end of file diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_patch.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_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/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_vendor.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_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/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_version.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/__init__.py new file mode 100644 index 000000000000..9e91fc7d791f --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/__init__.py @@ -0,0 +1,15 @@ +# 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 ._blockchain_management_client import BlockchainManagementClient +__all__ = ['BlockchainManagementClient'] + +# `._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/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_blockchain_management_client.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_blockchain_management_client.py new file mode 100644 index 000000000000..8ecb8c6c107c --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_blockchain_management_client.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import BlockchainManagementClientConfiguration +from .operations import BlockchainMemberOperationResultsOperations, BlockchainMembersOperations, LocationsOperations, Operations, SkusOperations, TransactionNodesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class BlockchainManagementClient: + """REST API for Azure Blockchain Service. + + :ivar blockchain_members: BlockchainMembersOperations operations + :vartype blockchain_members: + blockchain_management_client.aio.operations.BlockchainMembersOperations + :ivar blockchain_member_operation_results: BlockchainMemberOperationResultsOperations + operations + :vartype blockchain_member_operation_results: + blockchain_management_client.aio.operations.BlockchainMemberOperationResultsOperations + :ivar locations: LocationsOperations operations + :vartype locations: blockchain_management_client.aio.operations.LocationsOperations + :ivar operations: Operations operations + :vartype operations: blockchain_management_client.aio.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: blockchain_management_client.aio.operations.SkusOperations + :ivar transaction_nodes: TransactionNodesOperations operations + :vartype transaction_nodes: + blockchain_management_client.aio.operations.TransactionNodesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets the subscription Id which uniquely identifies the Microsoft Azure + subscription. The subscription ID is part of the URI for every service call. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BlockchainManagementClientConfiguration(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._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.blockchain_members = BlockchainMembersOperations(self._client, self._config, self._serialize, self._deserialize) + self.blockchain_member_operation_results = BlockchainMemberOperationResultsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.transaction_nodes = TransactionNodesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> 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.rest.AsyncHttpResponse + """ + + 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() + + async def __aenter__(self) -> "BlockchainManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_configuration.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_configuration.py new file mode 100644 index 000000000000..8b72dbb0e096 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class BlockchainManagementClientConfiguration(Configuration): + """Configuration for BlockchainManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Gets the subscription Id which uniquely identifies the Microsoft Azure subscription. The subscription ID is part of the URI for every service call. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(BlockchainManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2018-06-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-blockchain/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_patch.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/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/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/__init__.py new file mode 100644 index 000000000000..f1e1a3d8f7b1 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._blockchain_members_operations import BlockchainMembersOperations +from ._blockchain_member_operation_results_operations import BlockchainMemberOperationResultsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._transaction_nodes_operations import TransactionNodesOperations + +__all__ = [ + 'BlockchainMembersOperations', + 'BlockchainMemberOperationResultsOperations', + 'LocationsOperations', + 'Operations', + 'SkusOperations', + 'TransactionNodesOperations', +] diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_member_operation_results_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_member_operation_results_operations.py new file mode 100644 index 000000000000..7f8aca033b1a --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_member_operation_results_operations.py @@ -0,0 +1,98 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blockchain_member_operation_results_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlockchainMemberOperationResultsOperations: + """BlockchainMemberOperationResultsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + location_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional["_models.OperationResult"]: + """Get Async operation result. + + :param location_name: Location name. + :type location_name: str + :param operation_id: Operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResult, or the result of cls(response) + :rtype: ~blockchain_management_client.models.OperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + location_name=location_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/blockchainMemberOperationResults/{operationId}'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_members_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_members_operations.py new file mode 100644 index 000000000000..71fb86ae4fd0 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_blockchain_members_operations.py @@ -0,0 +1,713 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blockchain_members_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_all_request, build_list_api_keys_request, build_list_consortium_members_request, build_list_regenerate_api_keys_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlockchainMembersOperations: + """BlockchainMembersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.BlockchainMember": + """Get details about a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlockchainMember, or the result of cls(response) + :rtype: ~blockchain_management_client.models.BlockchainMember + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + async def _create_initial( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMember"] = None, + **kwargs: Any + ) -> "_models.BlockchainMember": + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if blockchain_member is not None: + _json = self._serialize.body(blockchain_member, 'BlockchainMember') + else: + _json = None + + request = build_create_request_initial( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMember"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.BlockchainMember"]: + """Create a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param blockchain_member: Payload to create a blockchain member. + :type blockchain_member: ~blockchain_management_client.models.BlockchainMember + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BlockchainMember or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~blockchain_management_client.models.BlockchainMember] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + blockchain_member_name=blockchain_member_name, + resource_group_name=resource_group_name, + blockchain_member=blockchain_member, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('BlockchainMember', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + async def _delete_initial( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + blockchain_member_name=blockchain_member_name, + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + @distributed_trace_async + async def update( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMemberUpdate"] = None, + **kwargs: Any + ) -> "_models.BlockchainMember": + """Update a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param blockchain_member: Payload to update the blockchain member. + :type blockchain_member: ~blockchain_management_client.models.BlockchainMemberUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlockchainMember, or the result of cls(response) + :rtype: ~blockchain_management_client.models.BlockchainMember + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if blockchain_member is not None: + _json = self._serialize.body(blockchain_member, 'BlockchainMemberUpdate') + else: + _json = None + + request = build_update_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.BlockchainMemberCollection"]: + """Lists the blockchain members for a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlockchainMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~blockchain_management_client.models.BlockchainMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BlockchainMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers'} # type: ignore + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable["_models.BlockchainMemberCollection"]: + """Lists the blockchain members for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlockchainMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~blockchain_management_client.models.BlockchainMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BlockchainMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/blockchainMembers'} # type: ignore + + @distributed_trace + def list_consortium_members( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ConsortiumMemberCollection"]: + """Lists the consortium members for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConsortiumMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~blockchain_management_client.models.ConsortiumMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConsortiumMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_consortium_members_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_consortium_members.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_consortium_members_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConsortiumMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_consortium_members.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/consortiumMembers'} # type: ignore + + @distributed_trace_async + async def list_api_keys( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Lists the API keys for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_api_keys_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/listApiKeys'} # type: ignore + + + @distributed_trace_async + async def list_regenerate_api_keys( + self, + blockchain_member_name: str, + resource_group_name: str, + api_key: Optional["_models.ApiKey"] = None, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Regenerate the API keys for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param api_key: api key to be regenerate. + :type api_key: ~blockchain_management_client.models.ApiKey + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if api_key is not None: + _json = self._serialize.body(api_key, 'ApiKey') + else: + _json = None + + request = build_list_regenerate_api_keys_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.list_regenerate_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_regenerate_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/regenerateApiKeys'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_locations_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_locations_operations.py new file mode 100644 index 000000000000..c6419ede4b0b --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_locations_operations.py @@ -0,0 +1,150 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._locations_operations import build_check_name_availability_request, build_list_consortiums_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LocationsOperations: + """LocationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def check_name_availability( + self, + location_name: str, + name_availability_request: Optional["_models.NameAvailabilityRequest"] = None, + **kwargs: Any + ) -> "_models.NameAvailability": + """To check whether a resource name is available. + + :param location_name: Location Name. + :type location_name: str + :param name_availability_request: Name availability request payload. + :type name_availability_request: ~blockchain_management_client.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~blockchain_management_client.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if name_availability_request is not None: + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + else: + _json = None + + request = build_check_name_availability_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/checkNameAvailability'} # type: ignore + + + @distributed_trace_async + async def list_consortiums( + self, + location_name: str, + **kwargs: Any + ) -> "_models.ConsortiumCollection": + """Lists the available consortiums for a subscription. + + :param location_name: Location Name. + :type location_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConsortiumCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ConsortiumCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConsortiumCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_consortiums_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_consortiums.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConsortiumCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_consortiums.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/listConsortiums'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_operations.py new file mode 100644 index 000000000000..1e1a713894af --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ResourceProviderOperationCollection"]: + """Lists the available operations of Microsoft.Blockchain resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~blockchain_management_client.models.ResourceProviderOperationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Blockchain/operations'} # type: ignore diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_skus_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..811c7d523734 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_skus_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SkusOperations: + """SkusOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def list( + self, + **kwargs: Any + ) -> "_models.ResourceTypeSkuCollection": + """Lists the Skus of the resource type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceTypeSkuCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ResourceTypeSkuCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceTypeSkuCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceTypeSkuCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/skus'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_transaction_nodes_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_transaction_nodes_operations.py new file mode 100644 index 000000000000..ed2f8ff79bb7 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/aio/operations/_transaction_nodes_operations.py @@ -0,0 +1,605 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._transaction_nodes_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_api_keys_request, build_list_regenerate_api_keys_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TransactionNodesOperations: + """TransactionNodesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.TransactionNode": + """Get the details of the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TransactionNode, or the result of cls(response) + :rtype: ~blockchain_management_client.models.TransactionNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + async def _create_initial( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNode"] = None, + **kwargs: Any + ) -> "_models.TransactionNode": + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if transaction_node is not None: + _json = self._serialize.body(transaction_node, 'TransactionNode') + else: + _json = None + + request = build_create_request_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNode"] = None, + **kwargs: Any + ) -> AsyncLROPoller["_models.TransactionNode"]: + """Create or update the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param transaction_node: Payload to create the transaction node. + :type transaction_node: ~blockchain_management_client.models.TransactionNode + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TransactionNode or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~blockchain_management_client.models.TransactionNode] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + resource_group_name=resource_group_name, + transaction_node=transaction_node, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('TransactionNode', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + async def _delete_initial( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + @distributed_trace_async + async def update( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNodeUpdate"] = None, + **kwargs: Any + ) -> "_models.TransactionNode": + """Update the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param transaction_node: Payload to create the transaction node. + :type transaction_node: ~blockchain_management_client.models.TransactionNodeUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TransactionNode, or the result of cls(response) + :rtype: ~blockchain_management_client.models.TransactionNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if transaction_node is not None: + _json = self._serialize.body(transaction_node, 'TransactionNodeUpdate') + else: + _json = None + + request = build_update_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace + def list( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.TransactionNodeCollection"]: + """Lists the transaction nodes for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TransactionNodeCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~blockchain_management_client.models.TransactionNodeCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNodeCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("TransactionNodeCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes'} # type: ignore + + @distributed_trace_async + async def list_api_keys( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """List the API keys for the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_api_keys_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/listApiKeys'} # type: ignore + + + @distributed_trace_async + async def list_regenerate_api_keys( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + api_key: Optional["_models.ApiKey"] = None, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Regenerate the API keys for the blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param api_key: api key to be regenerated. + :type api_key: ~blockchain_management_client.models.ApiKey + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if api_key is not None: + _json = self._serialize.body(api_key, 'ApiKey') + else: + _json = None + + request = build_list_regenerate_api_keys_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.list_regenerate_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_regenerate_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/regenerateApiKeys'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/__init__.py new file mode 100644 index 000000000000..2e8aa169ce27 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/__init__.py @@ -0,0 +1,79 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ApiKey +from ._models_py3 import ApiKeyCollection +from ._models_py3 import BlockchainMember +from ._models_py3 import BlockchainMemberCollection +from ._models_py3 import BlockchainMemberNodesSku +from ._models_py3 import BlockchainMemberPropertiesUpdate +from ._models_py3 import BlockchainMemberUpdate +from ._models_py3 import Consortium +from ._models_py3 import ConsortiumCollection +from ._models_py3 import ConsortiumMember +from ._models_py3 import ConsortiumMemberCollection +from ._models_py3 import FirewallRule +from ._models_py3 import NameAvailability +from ._models_py3 import NameAvailabilityRequest +from ._models_py3 import OperationResult +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationCollection +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceTypeSku +from ._models_py3 import ResourceTypeSkuCollection +from ._models_py3 import Sku +from ._models_py3 import SkuSetting +from ._models_py3 import TrackedResource +from ._models_py3 import TransactionNode +from ._models_py3 import TransactionNodeCollection +from ._models_py3 import TransactionNodePropertiesUpdate +from ._models_py3 import TransactionNodeUpdate + + +from ._blockchain_management_client_enums import ( + BlockchainMemberProvisioningState, + BlockchainProtocol, + NameAvailabilityReason, + NodeProvisioningState, +) + +__all__ = [ + 'ApiKey', + 'ApiKeyCollection', + 'BlockchainMember', + 'BlockchainMemberCollection', + 'BlockchainMemberNodesSku', + 'BlockchainMemberPropertiesUpdate', + 'BlockchainMemberUpdate', + 'Consortium', + 'ConsortiumCollection', + 'ConsortiumMember', + 'ConsortiumMemberCollection', + 'FirewallRule', + 'NameAvailability', + 'NameAvailabilityRequest', + 'OperationResult', + 'Resource', + 'ResourceProviderOperation', + 'ResourceProviderOperationCollection', + 'ResourceProviderOperationDisplay', + 'ResourceTypeSku', + 'ResourceTypeSkuCollection', + 'Sku', + 'SkuSetting', + 'TrackedResource', + 'TransactionNode', + 'TransactionNodeCollection', + 'TransactionNodePropertiesUpdate', + 'TransactionNodeUpdate', + 'BlockchainMemberProvisioningState', + 'BlockchainProtocol', + 'NameAvailabilityReason', + 'NodeProvisioningState', +] diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_blockchain_management_client_enums.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_blockchain_management_client_enums.py new file mode 100644 index 000000000000..24f11026273b --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_blockchain_management_client_enums.py @@ -0,0 +1,50 @@ +# 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 enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class BlockchainMemberProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets the blockchain member provision state. + """ + + NOT_SPECIFIED = "NotSpecified" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + STALE = "Stale" + +class BlockchainProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets the blockchain protocol. + """ + + NOT_SPECIFIED = "NotSpecified" + PARITY = "Parity" + QUORUM = "Quorum" + CORDA = "Corda" + +class NameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets the name availability reason. + """ + + NOT_SPECIFIED = "NotSpecified" + ALREADY_EXISTS = "AlreadyExists" + INVALID = "Invalid" + +class NodeProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Gets or sets the blockchain member provision state. + """ + + NOT_SPECIFIED = "NotSpecified" + UPDATING = "Updating" + DELETING = "Deleting" + SUCCEEDED = "Succeeded" + FAILED = "Failed" diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_models_py3.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_models_py3.py new file mode 100644 index 000000000000..858189220aa0 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/models/_models_py3.py @@ -0,0 +1,1213 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._blockchain_management_client_enums import * + + +class ApiKey(msrest.serialization.Model): + """API key payload which is exposed in the request/response of the resource provider. + + :ivar key_name: Gets or sets the API key name. + :vartype key_name: str + :ivar value: Gets or sets the API key value. + :vartype value: str + """ + + _attribute_map = { + 'key_name': {'key': 'keyName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + key_name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + """ + :keyword key_name: Gets or sets the API key name. + :paramtype key_name: str + :keyword value: Gets or sets the API key value. + :paramtype value: str + """ + super(ApiKey, self).__init__(**kwargs) + self.key_name = key_name + self.value = value + + +class ApiKeyCollection(msrest.serialization.Model): + """Collection of the API key payload which is exposed in the response of the resource provider. + + :ivar keys: Gets or sets the collection of API key. + :vartype keys: list[~blockchain_management_client.models.ApiKey] + """ + + _attribute_map = { + 'keys': {'key': 'keys', 'type': '[ApiKey]'}, + } + + def __init__( + self, + *, + keys: Optional[List["ApiKey"]] = None, + **kwargs + ): + """ + :keyword keys: Gets or sets the collection of API key. + :paramtype keys: list[~blockchain_management_client.models.ApiKey] + """ + super(ApiKeyCollection, self).__init__(**kwargs) + self.keys = keys + + +class Resource(msrest.serialization.Model): + """The core properties of the resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id of the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Blockchain". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class TrackedResource(Resource): + """The resource model definition for a top level resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id of the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Blockchain". + :vartype type: str + :ivar location: The GEO location of the blockchain service. + :vartype location: str + :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: The GEO location of the blockchain service. + :paramtype location: str + :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :paramtype tags: dict[str, str] + """ + super(TrackedResource, self).__init__(**kwargs) + self.location = location + self.tags = tags + + +class BlockchainMember(TrackedResource): + """Payload of the blockchain member which is exposed in the request/response of the resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id of the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Blockchain". + :vartype type: str + :ivar location: The GEO location of the blockchain service. + :vartype location: str + :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :vartype tags: dict[str, str] + :ivar sku: Gets or sets the blockchain member Sku. + :vartype sku: ~blockchain_management_client.models.Sku + :ivar protocol: Gets or sets the blockchain protocol. Possible values include: "NotSpecified", + "Parity", "Quorum", "Corda". + :vartype protocol: str or ~blockchain_management_client.models.BlockchainProtocol + :ivar validator_nodes_sku: Gets or sets the blockchain validator nodes Sku. + :vartype validator_nodes_sku: ~blockchain_management_client.models.BlockchainMemberNodesSku + :ivar provisioning_state: Gets or sets the blockchain member provision state. Possible values + include: "NotSpecified", "Updating", "Deleting", "Succeeded", "Failed", "Stale". + :vartype provisioning_state: str or + ~blockchain_management_client.models.BlockchainMemberProvisioningState + :ivar dns: Gets the dns endpoint of the blockchain member. + :vartype dns: str + :ivar user_name: Gets the auth user name of the blockchain member. + :vartype user_name: str + :ivar password: Sets the basic auth password of the blockchain member. + :vartype password: str + :ivar consortium: Gets or sets the consortium for the blockchain member. + :vartype consortium: str + :ivar consortium_management_account_address: Gets the managed consortium management account + address. + :vartype consortium_management_account_address: str + :ivar consortium_management_account_password: Sets the managed consortium management account + password. + :vartype consortium_management_account_password: str + :ivar consortium_role: Gets the role of the member in the consortium. + :vartype consortium_role: str + :ivar consortium_member_display_name: Gets the display name of the member in the consortium. + :vartype consortium_member_display_name: str + :ivar root_contract_address: Gets the Ethereum root contract address of the blockchain. + :vartype root_contract_address: str + :ivar public_key: Gets the public key of the blockchain member (default transaction node). + :vartype public_key: str + :ivar firewall_rules: Gets or sets firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'dns': {'readonly': True}, + 'user_name': {'readonly': True}, + 'consortium_management_account_address': {'readonly': True}, + 'root_contract_address': {'readonly': True}, + 'public_key': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'protocol': {'key': 'properties.protocol', 'type': 'str'}, + 'validator_nodes_sku': {'key': 'properties.validatorNodesSku', 'type': 'BlockchainMemberNodesSku'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'dns': {'key': 'properties.dns', 'type': 'str'}, + 'user_name': {'key': 'properties.userName', 'type': 'str'}, + 'password': {'key': 'properties.password', 'type': 'str'}, + 'consortium': {'key': 'properties.consortium', 'type': 'str'}, + 'consortium_management_account_address': {'key': 'properties.consortiumManagementAccountAddress', 'type': 'str'}, + 'consortium_management_account_password': {'key': 'properties.consortiumManagementAccountPassword', 'type': 'str'}, + 'consortium_role': {'key': 'properties.consortiumRole', 'type': 'str'}, + 'consortium_member_display_name': {'key': 'properties.consortiumMemberDisplayName', 'type': 'str'}, + 'root_contract_address': {'key': 'properties.rootContractAddress', 'type': 'str'}, + 'public_key': {'key': 'properties.publicKey', 'type': 'str'}, + 'firewall_rules': {'key': 'properties.firewallRules', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + sku: Optional["Sku"] = None, + protocol: Optional[Union[str, "BlockchainProtocol"]] = None, + validator_nodes_sku: Optional["BlockchainMemberNodesSku"] = None, + password: Optional[str] = None, + consortium: Optional[str] = None, + consortium_management_account_password: Optional[str] = None, + consortium_role: Optional[str] = None, + consortium_member_display_name: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + **kwargs + ): + """ + :keyword location: The GEO location of the blockchain service. + :paramtype location: str + :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :paramtype tags: dict[str, str] + :keyword sku: Gets or sets the blockchain member Sku. + :paramtype sku: ~blockchain_management_client.models.Sku + :keyword protocol: Gets or sets the blockchain protocol. Possible values include: + "NotSpecified", "Parity", "Quorum", "Corda". + :paramtype protocol: str or ~blockchain_management_client.models.BlockchainProtocol + :keyword validator_nodes_sku: Gets or sets the blockchain validator nodes Sku. + :paramtype validator_nodes_sku: ~blockchain_management_client.models.BlockchainMemberNodesSku + :keyword password: Sets the basic auth password of the blockchain member. + :paramtype password: str + :keyword consortium: Gets or sets the consortium for the blockchain member. + :paramtype consortium: str + :keyword consortium_management_account_password: Sets the managed consortium management account + password. + :paramtype consortium_management_account_password: str + :keyword consortium_role: Gets the role of the member in the consortium. + :paramtype consortium_role: str + :keyword consortium_member_display_name: Gets the display name of the member in the consortium. + :paramtype consortium_member_display_name: str + :keyword firewall_rules: Gets or sets firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + super(BlockchainMember, self).__init__(location=location, tags=tags, **kwargs) + self.sku = sku + self.protocol = protocol + self.validator_nodes_sku = validator_nodes_sku + self.provisioning_state = None + self.dns = None + self.user_name = None + self.password = password + self.consortium = consortium + self.consortium_management_account_address = None + self.consortium_management_account_password = consortium_management_account_password + self.consortium_role = consortium_role + self.consortium_member_display_name = consortium_member_display_name + self.root_contract_address = None + self.public_key = None + self.firewall_rules = firewall_rules + + +class BlockchainMemberCollection(msrest.serialization.Model): + """Collection of the blockchain member payload which is exposed in the request/response of the resource provider. + + :ivar value: Gets or sets the collection of blockchain members. + :vartype value: list[~blockchain_management_client.models.BlockchainMember] + :ivar next_link: Gets or sets the URL, that the client should use to fetch the next page (per + server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BlockchainMember]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["BlockchainMember"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of blockchain members. + :paramtype value: list[~blockchain_management_client.models.BlockchainMember] + :keyword next_link: Gets or sets the URL, that the client should use to fetch the next page + (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super(BlockchainMemberCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class BlockchainMemberNodesSku(msrest.serialization.Model): + """Payload of the blockchain member nodes Sku for a blockchain member. + + :ivar capacity: Gets or sets the nodes capacity. + :vartype capacity: int + """ + + _attribute_map = { + 'capacity': {'key': 'capacity', 'type': 'int'}, + } + + def __init__( + self, + *, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword capacity: Gets or sets the nodes capacity. + :paramtype capacity: int + """ + super(BlockchainMemberNodesSku, self).__init__(**kwargs) + self.capacity = capacity + + +class TransactionNodePropertiesUpdate(msrest.serialization.Model): + """Update the payload of the transaction node properties in the transaction node payload. + + :ivar password: Sets the transaction node dns endpoint basic auth password. + :vartype password: str + :ivar firewall_rules: Gets or sets the firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + + _attribute_map = { + 'password': {'key': 'password', 'type': 'str'}, + 'firewall_rules': {'key': 'firewallRules', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + password: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + **kwargs + ): + """ + :keyword password: Sets the transaction node dns endpoint basic auth password. + :paramtype password: str + :keyword firewall_rules: Gets or sets the firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + super(TransactionNodePropertiesUpdate, self).__init__(**kwargs) + self.password = password + self.firewall_rules = firewall_rules + + +class BlockchainMemberPropertiesUpdate(TransactionNodePropertiesUpdate): + """Update the payload of the blockchain member properties for a blockchain member. + + :ivar password: Sets the transaction node dns endpoint basic auth password. + :vartype password: str + :ivar firewall_rules: Gets or sets the firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + :ivar consortium_management_account_password: Sets the managed consortium management account + password. + :vartype consortium_management_account_password: str + """ + + _attribute_map = { + 'password': {'key': 'password', 'type': 'str'}, + 'firewall_rules': {'key': 'firewallRules', 'type': '[FirewallRule]'}, + 'consortium_management_account_password': {'key': 'consortiumManagementAccountPassword', 'type': 'str'}, + } + + def __init__( + self, + *, + password: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + consortium_management_account_password: Optional[str] = None, + **kwargs + ): + """ + :keyword password: Sets the transaction node dns endpoint basic auth password. + :paramtype password: str + :keyword firewall_rules: Gets or sets the firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + :keyword consortium_management_account_password: Sets the managed consortium management account + password. + :paramtype consortium_management_account_password: str + """ + super(BlockchainMemberPropertiesUpdate, self).__init__(password=password, firewall_rules=firewall_rules, **kwargs) + self.consortium_management_account_password = consortium_management_account_password + + +class BlockchainMemberUpdate(msrest.serialization.Model): + """Update the payload of the blockchain member which is exposed in the request/response of the resource provider. + + :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :vartype tags: dict[str, str] + :ivar password: Sets the transaction node dns endpoint basic auth password. + :vartype password: str + :ivar firewall_rules: Gets or sets the firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + :ivar consortium_management_account_password: Sets the managed consortium management account + password. + :vartype consortium_management_account_password: str + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'password': {'key': 'properties.password', 'type': 'str'}, + 'firewall_rules': {'key': 'properties.firewallRules', 'type': '[FirewallRule]'}, + 'consortium_management_account_password': {'key': 'properties.consortiumManagementAccountPassword', 'type': 'str'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + password: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + consortium_management_account_password: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that + describes the resource. + :paramtype tags: dict[str, str] + :keyword password: Sets the transaction node dns endpoint basic auth password. + :paramtype password: str + :keyword firewall_rules: Gets or sets the firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + :keyword consortium_management_account_password: Sets the managed consortium management account + password. + :paramtype consortium_management_account_password: str + """ + super(BlockchainMemberUpdate, self).__init__(**kwargs) + self.tags = tags + self.password = password + self.firewall_rules = firewall_rules + self.consortium_management_account_password = consortium_management_account_password + + +class Consortium(msrest.serialization.Model): + """Consortium payload. + + :ivar name: Gets or sets the blockchain member name. + :vartype name: str + :ivar protocol: Gets or sets the protocol for the consortium. Possible values include: + "NotSpecified", "Parity", "Quorum", "Corda". + :vartype protocol: str or ~blockchain_management_client.models.BlockchainProtocol + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'protocol': {'key': 'protocol', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + protocol: Optional[Union[str, "BlockchainProtocol"]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the blockchain member name. + :paramtype name: str + :keyword protocol: Gets or sets the protocol for the consortium. Possible values include: + "NotSpecified", "Parity", "Quorum", "Corda". + :paramtype protocol: str or ~blockchain_management_client.models.BlockchainProtocol + """ + super(Consortium, self).__init__(**kwargs) + self.name = name + self.protocol = protocol + + +class ConsortiumCollection(msrest.serialization.Model): + """Collection of the consortium payload. + + :ivar value: Gets or sets the collection of consortiums. + :vartype value: list[~blockchain_management_client.models.Consortium] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Consortium]'}, + } + + def __init__( + self, + *, + value: Optional[List["Consortium"]] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of consortiums. + :paramtype value: list[~blockchain_management_client.models.Consortium] + """ + super(ConsortiumCollection, self).__init__(**kwargs) + self.value = value + + +class ConsortiumMember(msrest.serialization.Model): + """Consortium approval. + + :ivar name: Gets the consortium member name. + :vartype name: str + :ivar display_name: Gets the consortium member display name. + :vartype display_name: str + :ivar subscription_id: Gets the consortium member subscription id. + :vartype subscription_id: str + :ivar role: Gets the consortium member role. + :vartype role: str + :ivar status: Gets the consortium member status. + :vartype status: str + :ivar join_date: Gets the consortium member join date. + :vartype join_date: ~datetime.datetime + :ivar date_modified: Gets the consortium member modified date. + :vartype date_modified: ~datetime.datetime + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + 'role': {'key': 'role', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'join_date': {'key': 'joinDate', 'type': 'iso-8601'}, + 'date_modified': {'key': 'dateModified', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + subscription_id: Optional[str] = None, + role: Optional[str] = None, + status: Optional[str] = None, + join_date: Optional[datetime.datetime] = None, + date_modified: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword name: Gets the consortium member name. + :paramtype name: str + :keyword display_name: Gets the consortium member display name. + :paramtype display_name: str + :keyword subscription_id: Gets the consortium member subscription id. + :paramtype subscription_id: str + :keyword role: Gets the consortium member role. + :paramtype role: str + :keyword status: Gets the consortium member status. + :paramtype status: str + :keyword join_date: Gets the consortium member join date. + :paramtype join_date: ~datetime.datetime + :keyword date_modified: Gets the consortium member modified date. + :paramtype date_modified: ~datetime.datetime + """ + super(ConsortiumMember, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + self.subscription_id = subscription_id + self.role = role + self.status = status + self.join_date = join_date + self.date_modified = date_modified + + +class ConsortiumMemberCollection(msrest.serialization.Model): + """Collection of consortium payload. + + :ivar value: Gets or sets the collection of consortiums. + :vartype value: list[~blockchain_management_client.models.ConsortiumMember] + :ivar next_link: Gets or sets the URL, that the client should use to fetch the next page (per + server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ConsortiumMember]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ConsortiumMember"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of consortiums. + :paramtype value: list[~blockchain_management_client.models.ConsortiumMember] + :keyword next_link: Gets or sets the URL, that the client should use to fetch the next page + (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super(ConsortiumMemberCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class FirewallRule(msrest.serialization.Model): + """Ip range for firewall rules. + + :ivar rule_name: Gets or sets the name of the firewall rules. + :vartype rule_name: str + :ivar start_ip_address: Gets or sets the start IP address of the firewall rule range. + :vartype start_ip_address: str + :ivar end_ip_address: Gets or sets the end IP address of the firewall rule range. + :vartype end_ip_address: str + """ + + _attribute_map = { + 'rule_name': {'key': 'ruleName', 'type': 'str'}, + 'start_ip_address': {'key': 'startIpAddress', 'type': 'str'}, + 'end_ip_address': {'key': 'endIpAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + rule_name: Optional[str] = None, + start_ip_address: Optional[str] = None, + end_ip_address: Optional[str] = None, + **kwargs + ): + """ + :keyword rule_name: Gets or sets the name of the firewall rules. + :paramtype rule_name: str + :keyword start_ip_address: Gets or sets the start IP address of the firewall rule range. + :paramtype start_ip_address: str + :keyword end_ip_address: Gets or sets the end IP address of the firewall rule range. + :paramtype end_ip_address: str + """ + super(FirewallRule, self).__init__(**kwargs) + self.rule_name = rule_name + self.start_ip_address = start_ip_address + self.end_ip_address = end_ip_address + + +class NameAvailability(msrest.serialization.Model): + """Name availability payload which is exposed in the response of the resource provider. + + :ivar name_available: Gets or sets the value indicating whether the name is available. + :vartype name_available: bool + :ivar message: Gets or sets the message. + :vartype message: str + :ivar reason: Gets or sets the name availability reason. Possible values include: + "NotSpecified", "AlreadyExists", "Invalid". + :vartype reason: str or ~blockchain_management_client.models.NameAvailabilityReason + """ + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'message': {'key': 'message', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + message: Optional[str] = None, + reason: Optional[Union[str, "NameAvailabilityReason"]] = None, + **kwargs + ): + """ + :keyword name_available: Gets or sets the value indicating whether the name is available. + :paramtype name_available: bool + :keyword message: Gets or sets the message. + :paramtype message: str + :keyword reason: Gets or sets the name availability reason. Possible values include: + "NotSpecified", "AlreadyExists", "Invalid". + :paramtype reason: str or ~blockchain_management_client.models.NameAvailabilityReason + """ + super(NameAvailability, self).__init__(**kwargs) + self.name_available = name_available + self.message = message + self.reason = reason + + +class NameAvailabilityRequest(msrest.serialization.Model): + """Name availability request payload which is exposed in the request of the resource provider. + + :ivar name: Gets or sets the name to check. + :vartype name: str + :ivar type: Gets or sets the type of the resource to check. + :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: Gets or sets the name to check. + :paramtype name: str + :keyword type: Gets or sets the type of the resource to check. + :paramtype type: str + """ + super(NameAvailabilityRequest, self).__init__(**kwargs) + self.name = name + self.type = type + + +class OperationResult(msrest.serialization.Model): + """Operation result payload which is exposed in the response of the resource provider. + + :ivar name: Gets or sets the operation name. + :vartype name: str + :ivar start_time: Gets or sets the operation start time. + :vartype start_time: ~datetime.datetime + :ivar end_time: Gets or sets the operation end time. + :vartype end_time: ~datetime.datetime + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the operation name. + :paramtype name: str + :keyword start_time: Gets or sets the operation start time. + :paramtype start_time: ~datetime.datetime + :keyword end_time: Gets or sets the operation end time. + :paramtype end_time: ~datetime.datetime + """ + super(OperationResult, self).__init__(**kwargs) + self.name = name + self.start_time = start_time + self.end_time = end_time + + +class ResourceProviderOperation(msrest.serialization.Model): + """Operation payload which is exposed in the response of the resource provider. + + :ivar origin: Gets or sets the origin. + :vartype origin: str + :ivar name: Gets or sets the operation name. + :vartype name: str + :ivar is_data_action: Gets or sets a value indicating whether the operation is a data action or + not. + :vartype is_data_action: bool + :ivar display: Gets or sets operation display. + :vartype display: ~blockchain_management_client.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'origin': {'key': 'origin', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + *, + origin: Optional[str] = None, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + """ + :keyword origin: Gets or sets the origin. + :paramtype origin: str + :keyword name: Gets or sets the operation name. + :paramtype name: str + :keyword is_data_action: Gets or sets a value indicating whether the operation is a data action + or not. + :paramtype is_data_action: bool + :keyword display: Gets or sets operation display. + :paramtype display: ~blockchain_management_client.models.ResourceProviderOperationDisplay + """ + super(ResourceProviderOperation, self).__init__(**kwargs) + self.origin = origin + self.name = name + self.is_data_action = is_data_action + self.display = display + + +class ResourceProviderOperationCollection(msrest.serialization.Model): + """Collection of operation payload which is exposed in the response of the resource provider. + + :ivar value: Gets or sets the collection of operations. + :vartype value: list[~blockchain_management_client.models.ResourceProviderOperation] + :ivar next_link: Gets or sets the URL, that the client should use to fetch the next page (per + server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of operations. + :paramtype value: list[~blockchain_management_client.models.ResourceProviderOperation] + :keyword next_link: Gets or sets the URL, that the client should use to fetch the next page + (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super(ResourceProviderOperationCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Operation display payload which is exposed in the response of the resource provider. + + :ivar provider: Gets or sets the name of the provider for display purposes. + :vartype provider: str + :ivar resource: Gets or sets the name of the resource type for display purposes. + :vartype resource: str + :ivar operation: Gets or sets the name of the operation for display purposes. + :vartype operation: str + :ivar description: Gets or sets the description of the provider for display purposes. + :vartype 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, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Gets or sets the name of the provider for display purposes. + :paramtype provider: str + :keyword resource: Gets or sets the name of the resource type for display purposes. + :paramtype resource: str + :keyword operation: Gets or sets the name of the operation for display purposes. + :paramtype operation: str + :keyword description: Gets or sets the description of the provider for display purposes. + :paramtype description: str + """ + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceTypeSku(msrest.serialization.Model): + """Resource type Sku. + + :ivar resource_type: Gets or sets the resource type. + :vartype resource_type: str + :ivar skus: Gets or sets the Skus. + :vartype skus: list[~blockchain_management_client.models.SkuSetting] + """ + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'skus': {'key': 'skus', 'type': '[SkuSetting]'}, + } + + def __init__( + self, + *, + resource_type: Optional[str] = None, + skus: Optional[List["SkuSetting"]] = None, + **kwargs + ): + """ + :keyword resource_type: Gets or sets the resource type. + :paramtype resource_type: str + :keyword skus: Gets or sets the Skus. + :paramtype skus: list[~blockchain_management_client.models.SkuSetting] + """ + super(ResourceTypeSku, self).__init__(**kwargs) + self.resource_type = resource_type + self.skus = skus + + +class ResourceTypeSkuCollection(msrest.serialization.Model): + """Collection of the resource type Sku. + + :ivar value: Gets or sets the collection of resource type Sku. + :vartype value: list[~blockchain_management_client.models.ResourceTypeSku] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceTypeSku]'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceTypeSku"]] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of resource type Sku. + :paramtype value: list[~blockchain_management_client.models.ResourceTypeSku] + """ + super(ResourceTypeSkuCollection, self).__init__(**kwargs) + self.value = value + + +class Sku(msrest.serialization.Model): + """Blockchain member Sku in payload. + + :ivar name: Gets or sets Sku name. + :vartype name: str + :ivar tier: Gets or sets Sku tier. + :vartype tier: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Gets or sets Sku name. + :paramtype name: str + :keyword tier: Gets or sets Sku tier. + :paramtype tier: str + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = tier + + +class SkuSetting(msrest.serialization.Model): + """Sku Setting. + + :ivar name: Gets or sets the Sku name. + :vartype name: str + :ivar tier: Gets or sets the Sku tier. + :vartype tier: str + :ivar locations: Gets or sets the locations. + :vartype locations: list[str] + :ivar required_features: Gets or sets the required features. + :vartype required_features: list[str] + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'required_features': {'key': 'requiredFeatures', 'type': '[str]'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + locations: Optional[List[str]] = None, + required_features: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the Sku name. + :paramtype name: str + :keyword tier: Gets or sets the Sku tier. + :paramtype tier: str + :keyword locations: Gets or sets the locations. + :paramtype locations: list[str] + :keyword required_features: Gets or sets the required features. + :paramtype required_features: list[str] + """ + super(SkuSetting, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.locations = locations + self.required_features = required_features + + +class TransactionNode(Resource): + """Payload of the transaction node which is the request/response of the resource provider. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource Id of the resource. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the service - e.g. "Microsoft.Blockchain". + :vartype type: str + :ivar location: Gets or sets the transaction node location. + :vartype location: str + :ivar provisioning_state: Gets or sets the blockchain member provision state. Possible values + include: "NotSpecified", "Updating", "Deleting", "Succeeded", "Failed". + :vartype provisioning_state: str or ~blockchain_management_client.models.NodeProvisioningState + :ivar dns: Gets or sets the transaction node dns endpoint. + :vartype dns: str + :ivar public_key: Gets or sets the transaction node public key. + :vartype public_key: str + :ivar user_name: Gets or sets the transaction node dns endpoint basic auth user name. + :vartype user_name: str + :ivar password: Sets the transaction node dns endpoint basic auth password. + :vartype password: str + :ivar firewall_rules: Gets or sets the firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'dns': {'readonly': True}, + 'public_key': {'readonly': True}, + 'user_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'dns': {'key': 'properties.dns', 'type': 'str'}, + 'public_key': {'key': 'properties.publicKey', 'type': 'str'}, + 'user_name': {'key': 'properties.userName', 'type': 'str'}, + 'password': {'key': 'properties.password', 'type': 'str'}, + 'firewall_rules': {'key': 'properties.firewallRules', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + password: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + **kwargs + ): + """ + :keyword location: Gets or sets the transaction node location. + :paramtype location: str + :keyword password: Sets the transaction node dns endpoint basic auth password. + :paramtype password: str + :keyword firewall_rules: Gets or sets the firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + super(TransactionNode, self).__init__(**kwargs) + self.location = location + self.provisioning_state = None + self.dns = None + self.public_key = None + self.user_name = None + self.password = password + self.firewall_rules = firewall_rules + + +class TransactionNodeCollection(msrest.serialization.Model): + """Collection of transaction node payload which is exposed in the request/response of the resource provider. + + :ivar value: Gets or sets the collection of transaction nodes. + :vartype value: list[~blockchain_management_client.models.TransactionNode] + :ivar next_link: Gets or sets the URL, that the client should use to fetch the next page (per + server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TransactionNode]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["TransactionNode"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the collection of transaction nodes. + :paramtype value: list[~blockchain_management_client.models.TransactionNode] + :keyword next_link: Gets or sets the URL, that the client should use to fetch the next page + (per server side paging). + It's null for now, added for future use. + :paramtype next_link: str + """ + super(TransactionNodeCollection, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class TransactionNodeUpdate(msrest.serialization.Model): + """Update the transaction node payload which is exposed in the request/response of the resource provider. + + :ivar password: Sets the transaction node dns endpoint basic auth password. + :vartype password: str + :ivar firewall_rules: Gets or sets the firewall rules. + :vartype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + + _attribute_map = { + 'password': {'key': 'properties.password', 'type': 'str'}, + 'firewall_rules': {'key': 'properties.firewallRules', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + password: Optional[str] = None, + firewall_rules: Optional[List["FirewallRule"]] = None, + **kwargs + ): + """ + :keyword password: Sets the transaction node dns endpoint basic auth password. + :paramtype password: str + :keyword firewall_rules: Gets or sets the firewall rules. + :paramtype firewall_rules: list[~blockchain_management_client.models.FirewallRule] + """ + super(TransactionNodeUpdate, self).__init__(**kwargs) + self.password = password + self.firewall_rules = firewall_rules diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/__init__.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/__init__.py new file mode 100644 index 000000000000..f1e1a3d8f7b1 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._blockchain_members_operations import BlockchainMembersOperations +from ._blockchain_member_operation_results_operations import BlockchainMemberOperationResultsOperations +from ._locations_operations import LocationsOperations +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._transaction_nodes_operations import TransactionNodesOperations + +__all__ = [ + 'BlockchainMembersOperations', + 'BlockchainMemberOperationResultsOperations', + 'LocationsOperations', + 'Operations', + 'SkusOperations', + 'TransactionNodesOperations', +] diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_member_operation_results_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_member_operation_results_operations.py new file mode 100644 index 000000000000..1f3f5ad45398 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_member_operation_results_operations.py @@ -0,0 +1,135 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + location_name: str, + operation_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/blockchainMemberOperationResults/{operationId}') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class BlockchainMemberOperationResultsOperations(object): + """BlockchainMemberOperationResultsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + location_name: str, + operation_id: str, + **kwargs: Any + ) -> Optional["_models.OperationResult"]: + """Get Async operation result. + + :param location_name: Location name. + :type location_name: str + :param operation_id: Operation Id. + :type operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationResult, or the result of cls(response) + :rtype: ~blockchain_management_client.models.OperationResult or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationResult"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + location_name=location_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('OperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/blockchainMemberOperationResults/{operationId}'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_members_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_members_operations.py new file mode 100644 index 000000000000..f1ab2ff1c052 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_blockchain_members_operations.py @@ -0,0 +1,1044 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_all_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/blockchainMembers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_consortium_members_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/consortiumMembers') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_api_keys_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/listApiKeys') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_regenerate_api_keys_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/regenerateApiKeys') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class BlockchainMembersOperations(object): + """BlockchainMembersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.BlockchainMember": + """Get details about a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlockchainMember, or the result of cls(response) + :rtype: ~blockchain_management_client.models.BlockchainMember + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + def _create_initial( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMember"] = None, + **kwargs: Any + ) -> "_models.BlockchainMember": + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if blockchain_member is not None: + _json = self._serialize.body(blockchain_member, 'BlockchainMember') + else: + _json = None + + request = build_create_request_initial( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace + def begin_create( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMember"] = None, + **kwargs: Any + ) -> LROPoller["_models.BlockchainMember"]: + """Create a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param blockchain_member: Payload to create a blockchain member. + :type blockchain_member: ~blockchain_management_client.models.BlockchainMember + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BlockchainMember or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~blockchain_management_client.models.BlockchainMember] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + blockchain_member_name=blockchain_member_name, + resource_group_name=resource_group_name, + blockchain_member=blockchain_member, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('BlockchainMember', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + def _delete_initial( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + blockchain_member_name=blockchain_member_name, + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + @distributed_trace + def update( + self, + blockchain_member_name: str, + resource_group_name: str, + blockchain_member: Optional["_models.BlockchainMemberUpdate"] = None, + **kwargs: Any + ) -> "_models.BlockchainMember": + """Update a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param blockchain_member: Payload to update the blockchain member. + :type blockchain_member: ~blockchain_management_client.models.BlockchainMemberUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlockchainMember, or the result of cls(response) + :rtype: ~blockchain_management_client.models.BlockchainMember + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMember"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if blockchain_member is not None: + _json = self._serialize.body(blockchain_member, 'BlockchainMemberUpdate') + else: + _json = None + + request = build_update_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlockchainMember', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.BlockchainMemberCollection"]: + """Lists the blockchain members for a resource group. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlockchainMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~blockchain_management_client.models.BlockchainMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BlockchainMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers'} # type: ignore + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> Iterable["_models.BlockchainMemberCollection"]: + """Lists the blockchain members for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlockchainMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~blockchain_management_client.models.BlockchainMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlockchainMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BlockchainMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/blockchainMembers'} # type: ignore + + @distributed_trace + def list_consortium_members( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ConsortiumMemberCollection"]: + """Lists the consortium members for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConsortiumMemberCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~blockchain_management_client.models.ConsortiumMemberCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConsortiumMemberCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_consortium_members_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_consortium_members.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_consortium_members_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConsortiumMemberCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_consortium_members.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/consortiumMembers'} # type: ignore + + @distributed_trace + def list_api_keys( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Lists the API keys for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_api_keys_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/listApiKeys'} # type: ignore + + + @distributed_trace + def list_regenerate_api_keys( + self, + blockchain_member_name: str, + resource_group_name: str, + api_key: Optional["_models.ApiKey"] = None, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Regenerate the API keys for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param api_key: api key to be regenerate. + :type api_key: ~blockchain_management_client.models.ApiKey + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if api_key is not None: + _json = self._serialize.body(api_key, 'ApiKey') + else: + _json = None + + request = build_list_regenerate_api_keys_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.list_regenerate_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_regenerate_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/regenerateApiKeys'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_locations_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_locations_operations.py new file mode 100644 index 000000000000..55b5fe34fb28 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_locations_operations.py @@ -0,0 +1,228 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +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( + location_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/checkNameAvailability') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_consortiums_request( + location_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/listConsortiums') + path_format_arguments = { + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class LocationsOperations(object): + """LocationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def check_name_availability( + self, + location_name: str, + name_availability_request: Optional["_models.NameAvailabilityRequest"] = None, + **kwargs: Any + ) -> "_models.NameAvailability": + """To check whether a resource name is available. + + :param location_name: Location Name. + :type location_name: str + :param name_availability_request: Name availability request payload. + :type name_availability_request: ~blockchain_management_client.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~blockchain_management_client.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if name_availability_request is not None: + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + else: + _json = None + + request = build_check_name_availability_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/checkNameAvailability'} # type: ignore + + + @distributed_trace + def list_consortiums( + self, + location_name: str, + **kwargs: Any + ) -> "_models.ConsortiumCollection": + """Lists the available consortiums for a subscription. + + :param location_name: Location Name. + :type location_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConsortiumCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ConsortiumCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConsortiumCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_consortiums_request( + location_name=location_name, + subscription_id=self._config.subscription_id, + template_url=self.list_consortiums.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ConsortiumCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_consortiums.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/locations/{locationName}/listConsortiums'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_operations.py new file mode 100644 index 000000000000..19df22e9ec85 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_operations.py @@ -0,0 +1,136 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +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 = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Blockchain/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. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ResourceProviderOperationCollection"]: + """Lists the available operations of Microsoft.Blockchain resource provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourceProviderOperationCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~blockchain_management_client.models.ResourceProviderOperationCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ResourceProviderOperationCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Blockchain/operations'} # type: ignore diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_skus_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_skus_operations.py new file mode 100644 index 000000000000..3e15aaa5fb59 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_skus_operations.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/skus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class SkusOperations(object): + """SkusOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> "_models.ResourceTypeSkuCollection": + """Lists the Skus of the resource type. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourceTypeSkuCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ResourceTypeSkuCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceTypeSkuCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourceTypeSkuCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Blockchain/skus'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_transaction_nodes_operations.py b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_transaction_nodes_operations.py new file mode 100644 index 000000000000..a9f7fbb784b8 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/operations/_transaction_nodes_operations.py @@ -0,0 +1,884 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request_initial( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_update_request( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + blockchain_member_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_api_keys_request( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/listApiKeys') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_regenerate_api_keys_request( + blockchain_member_name: str, + transaction_node_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/regenerateApiKeys') + path_format_arguments = { + "blockchainMemberName": _SERIALIZER.url("blockchain_member_name", blockchain_member_name, 'str'), + "transactionNodeName": _SERIALIZER.url("transaction_node_name", transaction_node_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class TransactionNodesOperations(object): + """TransactionNodesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~blockchain_management_client.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.TransactionNode": + """Get the details of the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TransactionNode, or the result of cls(response) + :rtype: ~blockchain_management_client.models.TransactionNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + def _create_initial( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNode"] = None, + **kwargs: Any + ) -> "_models.TransactionNode": + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if transaction_node is not None: + _json = self._serialize.body(transaction_node, 'TransactionNode') + else: + _json = None + + request = build_create_request_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + 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(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace + def begin_create( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNode"] = None, + **kwargs: Any + ) -> LROPoller["_models.TransactionNode"]: + """Create or update the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param transaction_node: Payload to create the transaction node. + :type transaction_node: ~blockchain_management_client.models.TransactionNode + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TransactionNode or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~blockchain_management_client.models.TransactionNode] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + resource_group_name=resource_group_name, + transaction_node=transaction_node, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('TransactionNode', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + def _delete_initial( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Delete the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + resource_group_name=resource_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + @distributed_trace + def update( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + transaction_node: Optional["_models.TransactionNodeUpdate"] = None, + **kwargs: Any + ) -> "_models.TransactionNode": + """Update the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param transaction_node: Payload to create the transaction node. + :type transaction_node: ~blockchain_management_client.models.TransactionNodeUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TransactionNode, or the result of cls(response) + :rtype: ~blockchain_management_client.models.TransactionNode + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNode"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if transaction_node is not None: + _json = self._serialize.body(transaction_node, 'TransactionNodeUpdate') + else: + _json = None + + request = build_update_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TransactionNode', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}'} # type: ignore + + + @distributed_trace + def list( + self, + blockchain_member_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.TransactionNodeCollection"]: + """Lists the transaction nodes for a blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TransactionNodeCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~blockchain_management_client.models.TransactionNodeCollection] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionNodeCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + blockchain_member_name=blockchain_member_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("TransactionNodeCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes'} # type: ignore + + @distributed_trace + def list_api_keys( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """List the API keys for the transaction node. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_list_api_keys_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/listApiKeys'} # type: ignore + + + @distributed_trace + def list_regenerate_api_keys( + self, + blockchain_member_name: str, + transaction_node_name: str, + resource_group_name: str, + api_key: Optional["_models.ApiKey"] = None, + **kwargs: Any + ) -> "_models.ApiKeyCollection": + """Regenerate the API keys for the blockchain member. + + :param blockchain_member_name: Blockchain member name. + :type blockchain_member_name: str + :param transaction_node_name: Transaction node name. + :type transaction_node_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. + :type resource_group_name: str + :param api_key: api key to be regenerated. + :type api_key: ~blockchain_management_client.models.ApiKey + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ApiKeyCollection, or the result of cls(response) + :rtype: ~blockchain_management_client.models.ApiKeyCollection + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ApiKeyCollection"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if api_key is not None: + _json = self._serialize.body(api_key, 'ApiKey') + else: + _json = None + + request = build_list_regenerate_api_keys_request( + blockchain_member_name=blockchain_member_name, + transaction_node_name=transaction_node_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.list_regenerate_api_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ApiKeyCollection', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_regenerate_api_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Blockchain/blockchainMembers/{blockchainMemberName}/transactionNodes/{transactionNodeName}/regenerateApiKeys'} # type: ignore + diff --git a/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/py.typed b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/azure/mgmt/blockchain/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/blockchain/azure-mgmt-blockchain/sdk_packaging.toml b/sdk/blockchain/azure-mgmt-blockchain/sdk_packaging.toml new file mode 100644 index 000000000000..713152ae5e51 --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-blockchain" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/blockchain/azure-mgmt-blockchain/setup.py b/sdk/blockchain/azure-mgmt-blockchain/setup.py new file mode 100644 index 000000000000..09be8641e3fa --- /dev/null +++ b/sdk/blockchain/azure-mgmt-blockchain/setup.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-blockchain" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'azure-common~=1.1', + 'azure-mgmt-core>=1.3.0,<2.0.0', + ], + python_requires=">=3.6" +) diff --git a/sdk/blockchain/ci.yml b/sdk/blockchain/ci.yml new file mode 100644 index 000000000000..79c7da171e28 --- /dev/null +++ b/sdk/blockchain/ci.yml @@ -0,0 +1,33 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/blockchain/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/blockchain/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: blockchain + Artifacts: + - name: azure-mgmt-blockchain + safeName: azuremgmtblockchain