From 9b035326dca7f028f9c4a6e59f1aa5fc2ef64487 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 24 Mar 2022 07:04:56 +0000 Subject: [PATCH] CodeGen from PR 18387 in Azure/azure-rest-api-specs Merge 285e087686fb20c4aecf62f528dd7d3ebf733c74 into ce6e1414f546d09834a24dc24814b2b8e932b1de --- .../azure-mgmt-blueprint/CHANGELOG.md | 5 + sdk/blueprint/azure-mgmt-blueprint/LICENSE | 21 + .../azure-mgmt-blueprint/MANIFEST.in | 6 + sdk/blueprint/azure-mgmt-blueprint/README.md | 30 + sdk/blueprint/azure-mgmt-blueprint/_meta.json | 11 + .../azure-mgmt-blueprint/azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + .../azure/mgmt/blueprint/__init__.py | 18 + .../blueprint/_blueprint_management_client.py | 103 + .../azure/mgmt/blueprint/_configuration.py | 62 + .../azure/mgmt/blueprint/_metadata.json | 95 + .../azure/mgmt/blueprint/_patch.py | 31 + .../azure/mgmt/blueprint/_vendor.py | 27 + .../azure/mgmt/blueprint/_version.py | 9 + .../azure/mgmt/blueprint/aio/__init__.py | 15 + .../aio/_blueprint_management_client.py | 102 + .../mgmt/blueprint/aio/_configuration.py | 61 + .../azure/mgmt/blueprint/aio/_patch.py | 31 + .../mgmt/blueprint/aio/operations/__init__.py | 23 + .../aio/operations/_artifacts_operations.py | 298 ++ .../_assignment_operations_operations.py | 178 ++ .../aio/operations/_assignments_operations.py | 338 +++ .../aio/operations/_blueprints_operations.py | 281 ++ .../_published_artifacts_operations.py | 185 ++ .../_published_blueprints_operations.py | 304 ++ .../azure/mgmt/blueprint/models/__init__.py | 121 + .../_blueprint_management_client_enums.py | 78 + .../mgmt/blueprint/models/_models_py3.py | 2495 +++++++++++++++++ .../mgmt/blueprint/operations/__init__.py | 23 + .../operations/_artifacts_operations.py | 447 +++ .../_assignment_operations_operations.py | 246 ++ .../operations/_assignments_operations.py | 516 ++++ .../operations/_blueprints_operations.py | 422 +++ .../_published_artifacts_operations.py | 258 ++ .../_published_blueprints_operations.py | 452 +++ .../azure/mgmt/blueprint/py.typed | 1 + .../azure-mgmt-blueprint/sdk_packaging.toml | 9 + sdk/blueprint/azure-mgmt-blueprint/setup.py | 74 + sdk/blueprint/ci.yml | 33 + 39 files changed, 7411 insertions(+) create mode 100644 sdk/blueprint/azure-mgmt-blueprint/CHANGELOG.md create mode 100644 sdk/blueprint/azure-mgmt-blueprint/LICENSE create mode 100644 sdk/blueprint/azure-mgmt-blueprint/MANIFEST.in create mode 100644 sdk/blueprint/azure-mgmt-blueprint/README.md create mode 100644 sdk/blueprint/azure-mgmt-blueprint/_meta.json create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_blueprint_management_client.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_configuration.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_metadata.json create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_patch.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_vendor.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_version.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_blueprint_management_client.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_configuration.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_patch.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_artifacts_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignment_operations_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignments_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_blueprints_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_artifacts_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_blueprints_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_blueprint_management_client_enums.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_models_py3.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/__init__.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_artifacts_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignment_operations_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignments_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_blueprints_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_artifacts_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_blueprints_operations.py create mode 100644 sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/py.typed create mode 100644 sdk/blueprint/azure-mgmt-blueprint/sdk_packaging.toml create mode 100644 sdk/blueprint/azure-mgmt-blueprint/setup.py create mode 100644 sdk/blueprint/ci.yml diff --git a/sdk/blueprint/azure-mgmt-blueprint/CHANGELOG.md b/sdk/blueprint/azure-mgmt-blueprint/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/blueprint/azure-mgmt-blueprint/LICENSE b/sdk/blueprint/azure-mgmt-blueprint/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/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/blueprint/azure-mgmt-blueprint/MANIFEST.in b/sdk/blueprint/azure-mgmt-blueprint/MANIFEST.in new file mode 100644 index 000000000000..2c31e8da0cb1 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/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/blueprint/azure-mgmt-blueprint/README.md b/sdk/blueprint/azure-mgmt-blueprint/README.md new file mode 100644 index 000000000000..4f00c56d86af --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/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.6+. +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-blueprint%2FREADME.png) diff --git a/sdk/blueprint/azure-mgmt-blueprint/_meta.json b/sdk/blueprint/azure-mgmt-blueprint/_meta.json new file mode 100644 index 000000000000..599ca273f4cc --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "55f588f347e3d3bfe6dccbcd7fd9792c109b1181", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/blueprint/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/blueprint/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/__init__.py new file mode 100644 index 000000000000..5e806c178d52 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/__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 ._blueprint_management_client import BlueprintManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['BlueprintManagementClient'] + +# `._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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_blueprint_management_client.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_blueprint_management_client.py new file mode 100644 index 000000000000..f06acde7468c --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_blueprint_management_client.py @@ -0,0 +1,103 @@ +# 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 BlueprintManagementClientConfiguration +from .operations import ArtifactsOperations, AssignmentOperationsOperations, AssignmentsOperations, BlueprintsOperations, PublishedArtifactsOperations, PublishedBlueprintsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class BlueprintManagementClient: + """Blueprint Client. + + :ivar blueprints: BlueprintsOperations operations + :vartype blueprints: azure.mgmt.blueprint.operations.BlueprintsOperations + :ivar artifacts: ArtifactsOperations operations + :vartype artifacts: azure.mgmt.blueprint.operations.ArtifactsOperations + :ivar published_blueprints: PublishedBlueprintsOperations operations + :vartype published_blueprints: azure.mgmt.blueprint.operations.PublishedBlueprintsOperations + :ivar published_artifacts: PublishedArtifactsOperations operations + :vartype published_artifacts: azure.mgmt.blueprint.operations.PublishedArtifactsOperations + :ivar assignments: AssignmentsOperations operations + :vartype assignments: azure.mgmt.blueprint.operations.AssignmentsOperations + :ivar assignment_operations: AssignmentOperationsOperations operations + :vartype assignment_operations: azure.mgmt.blueprint.operations.AssignmentOperationsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + """ + + def __init__( + self, + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BlueprintManagementClientConfiguration(credential=credential, **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.blueprints = BlueprintsOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifacts = ArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.published_blueprints = PublishedBlueprintsOperations(self._client, self._config, self._serialize, self._deserialize) + self.published_artifacts = PublishedArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.assignments = AssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.assignment_operations = AssignmentOperationsOperations(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: () -> BlueprintManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_configuration.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_configuration.py new file mode 100644 index 000000000000..88bbe53aa855 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_configuration.py @@ -0,0 +1,62 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 BlueprintManagementClientConfiguration(Configuration): + """Configuration for BlueprintManagementClient. + + 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 + """ + + def __init__( + self, + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(BlueprintManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = "2018-11-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-blueprint/{}'.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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_metadata.json b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_metadata.json new file mode 100644 index 000000000000..5edf073700c4 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_metadata.json @@ -0,0 +1,95 @@ +{ + "chosen_version": "2018-11-01-preview", + "total_api_version_list": ["2018-11-01-preview"], + "client": { + "name": "BlueprintManagementClient", + "filename": "_blueprint_management_client", + "description": "Blueprint Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "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\": [\"BlueprintManagementClientConfiguration\"]}}, \"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\": [\"BlueprintManagementClientConfiguration\"]}}, \"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 + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "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": { + "blueprints": "BlueprintsOperations", + "artifacts": "ArtifactsOperations", + "published_blueprints": "PublishedBlueprintsOperations", + "published_artifacts": "PublishedArtifactsOperations", + "assignments": "AssignmentsOperations", + "assignment_operations": "AssignmentOperationsOperations" + } +} \ No newline at end of file diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_patch.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_vendor.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_version.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/_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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/__init__.py new file mode 100644 index 000000000000..f2fa1d922fc4 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/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 ._blueprint_management_client import BlueprintManagementClient +__all__ = ['BlueprintManagementClient'] + +# `._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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_blueprint_management_client.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_blueprint_management_client.py new file mode 100644 index 000000000000..10dc4ed74063 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_blueprint_management_client.py @@ -0,0 +1,102 @@ +# 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 BlueprintManagementClientConfiguration +from .operations import ArtifactsOperations, AssignmentOperationsOperations, AssignmentsOperations, BlueprintsOperations, PublishedArtifactsOperations, PublishedBlueprintsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class BlueprintManagementClient: + """Blueprint Client. + + :ivar blueprints: BlueprintsOperations operations + :vartype blueprints: azure.mgmt.blueprint.aio.operations.BlueprintsOperations + :ivar artifacts: ArtifactsOperations operations + :vartype artifacts: azure.mgmt.blueprint.aio.operations.ArtifactsOperations + :ivar published_blueprints: PublishedBlueprintsOperations operations + :vartype published_blueprints: + azure.mgmt.blueprint.aio.operations.PublishedBlueprintsOperations + :ivar published_artifacts: PublishedArtifactsOperations operations + :vartype published_artifacts: azure.mgmt.blueprint.aio.operations.PublishedArtifactsOperations + :ivar assignments: AssignmentsOperations operations + :vartype assignments: azure.mgmt.blueprint.aio.operations.AssignmentsOperations + :ivar assignment_operations: AssignmentOperationsOperations operations + :vartype assignment_operations: + azure.mgmt.blueprint.aio.operations.AssignmentOperationsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BlueprintManagementClientConfiguration(credential=credential, **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.blueprints = BlueprintsOperations(self._client, self._config, self._serialize, self._deserialize) + self.artifacts = ArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.published_blueprints = PublishedBlueprintsOperations(self._client, self._config, self._serialize, self._deserialize) + self.published_artifacts = PublishedArtifactsOperations(self._client, self._config, self._serialize, self._deserialize) + self.assignments = AssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.assignment_operations = AssignmentOperationsOperations(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) -> "BlueprintManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_configuration.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_configuration.py new file mode 100644 index 000000000000..c0514327fbb7 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_configuration.py @@ -0,0 +1,61 @@ +# 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 BlueprintManagementClientConfiguration(Configuration): + """Configuration for BlueprintManagementClient. + + 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 + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + super(BlueprintManagementClientConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = "2018-11-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-blueprint/{}'.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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_patch.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/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/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/__init__.py new file mode 100644 index 000000000000..b5c4b8a1b2c2 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/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 ._blueprints_operations import BlueprintsOperations +from ._artifacts_operations import ArtifactsOperations +from ._published_blueprints_operations import PublishedBlueprintsOperations +from ._published_artifacts_operations import PublishedArtifactsOperations +from ._assignments_operations import AssignmentsOperations +from ._assignment_operations_operations import AssignmentOperationsOperations + +__all__ = [ + 'BlueprintsOperations', + 'ArtifactsOperations', + 'PublishedBlueprintsOperations', + 'PublishedArtifactsOperations', + 'AssignmentsOperations', + 'AssignmentOperationsOperations', +] diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_artifacts_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_artifacts_operations.py new file mode 100644 index 000000000000..e15dc51e044f --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_artifacts_operations.py @@ -0,0 +1,298 @@ +# 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._artifacts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ArtifactsOperations: + """ArtifactsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + artifact: "_models.Artifact", + **kwargs: Any + ) -> "_models.Artifact": + """Create or update blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :param artifact: Blueprint artifact to create or update. + :type artifact: ~azure.mgmt.blueprint.models.Artifact + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(artifact, 'Artifact') + + request = build_create_or_update_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any + ) -> "_models.Artifact": + """Get a blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_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('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any + ) -> Optional["_models.Artifact"]: + """Delete a blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Artifact"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ArtifactList"]: + """List artifacts for a given blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArtifactList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.ArtifactList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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("ArtifactList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignment_operations_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignment_operations_operations.py new file mode 100644 index 000000000000..72cfbde0de51 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignment_operations_operations.py @@ -0,0 +1,178 @@ +# 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._assignment_operations_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AssignmentOperationsOperations: + """AssignmentOperationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AssignmentOperationList"]: + """List operations for given blueprint assignment within a subscription or a management group. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssignmentOperationList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.AssignmentOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentOperationList"] + 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( + resource_scope=resource_scope, + assignment_name=assignment_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + assignment_name=assignment_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("AssignmentOperationList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_scope: str, + assignment_name: str, + assignment_operation_name: str, + **kwargs: Any + ) -> "_models.AssignmentOperation": + """Get a blueprint assignment operation. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param assignment_operation_name: Name of the blueprint assignment operation. + :type assignment_operation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AssignmentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.AssignmentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + assignment_operation_name=assignment_operation_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('AssignmentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations/{assignmentOperationName}'} # type: ignore + diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignments_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignments_operations.py new file mode 100644 index 000000000000..cc0c19ebad66 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_assignments_operations.py @@ -0,0 +1,338 @@ +# 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.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._assignments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_who_is_blueprint_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AssignmentsOperations: + """AssignmentsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + assignment_name: str, + assignment: "_models.Assignment", + **kwargs: Any + ) -> "_models.Assignment": + """Create or update a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param assignment: Blueprint assignment object to save. + :type assignment: ~azure.mgmt.blueprint.models.Assignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Assignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(assignment, 'Assignment') + + request = build_create_or_update_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> "_models.Assignment": + """Get a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Assignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + assignment_name=assignment_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('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_scope: str, + assignment_name: str, + delete_behavior: Optional[Union[str, "_models.AssignmentDeleteBehavior"]] = None, + **kwargs: Any + ) -> Optional["_models.Assignment"]: + """Delete a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param delete_behavior: When deleteBehavior=all, the resources that were created by the + blueprint assignment will be deleted. + :type delete_behavior: str or ~azure.mgmt.blueprint.models.AssignmentDeleteBehavior + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Assignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + delete_behavior=delete_behavior, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 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 == 202: + deserialized = self._deserialize('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace_async + async def who_is_blueprint( + self, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> "_models.WhoIsBlueprintContract": + """Get Blueprints service SPN objectId. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WhoIsBlueprintContract, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.WhoIsBlueprintContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhoIsBlueprintContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_who_is_blueprint_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + template_url=self.who_is_blueprint.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('WhoIsBlueprintContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + who_is_blueprint.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/whoIsBlueprint'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + **kwargs: Any + ) -> AsyncIterable["_models.AssignmentList"]: + """List blueprint assignments within a subscription or a management group. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssignmentList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.AssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentList"] + 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( + resource_scope=resource_scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AssignmentList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_blueprints_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_blueprints_operations.py new file mode 100644 index 000000000000..4664d3998e54 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_blueprints_operations.py @@ -0,0 +1,281 @@ +# 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._blueprints_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlueprintsOperations: + """BlueprintsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + blueprint_name: str, + blueprint: "_models.Blueprint", + **kwargs: Any + ) -> "_models.Blueprint": + """Create or update a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param blueprint: Blueprint definition. + :type blueprint: ~azure.mgmt.blueprint.models.Blueprint + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Blueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(blueprint, 'Blueprint') + + request = build_create_or_update_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> "_models.Blueprint": + """Get a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Blueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> Optional["_models.Blueprint"]: + """Delete a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Blueprint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + **kwargs: Any + ) -> AsyncIterable["_models.BlueprintList"]: + """List blueprint definitions. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlueprintList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.BlueprintList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlueprintList"] + 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( + resource_scope=resource_scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BlueprintList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_artifacts_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_artifacts_operations.py new file mode 100644 index 000000000000..3d2c92d675cf --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_artifacts_operations.py @@ -0,0 +1,185 @@ +# 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._published_artifacts_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PublishedArtifactsOperations: + """PublishedArtifactsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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, + resource_scope: str, + blueprint_name: str, + version_id: str, + artifact_name: str, + **kwargs: Any + ) -> "_models.Artifact": + """Get an artifact for a published blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + artifact_name=artifact_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('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> AsyncIterable["_models.ArtifactList"]: + """List artifacts for a version of a published blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArtifactList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.ArtifactList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_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("ArtifactList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_blueprints_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_blueprints_operations.py new file mode 100644 index 000000000000..9b0c5d54064f --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/aio/operations/_published_blueprints_operations.py @@ -0,0 +1,304 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +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._published_blueprints_operations import build_create_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PublishedBlueprintsOperations: + """PublishedBlueprintsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + published_blueprint: Optional["_models.PublishedBlueprint"] = None, + **kwargs: Any + ) -> "_models.PublishedBlueprint": + """Publish a new version of the blueprint definition with the latest artifacts. Published + blueprint definitions are immutable. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :param published_blueprint: Published Blueprint to create or update. + :type published_blueprint: ~azure.mgmt.blueprint.models.PublishedBlueprint + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprint"] + 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 published_blueprint is not None: + _json = self._serialize.body(published_blueprint, 'PublishedBlueprint') + else: + _json = None + + request = build_create_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> "_models.PublishedBlueprint": + """Get a published version of a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> Optional["_models.PublishedBlueprint"]: + """Delete a published version of a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PublishedBlueprint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.PublishedBlueprintList"]: + """List published versions of given blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PublishedBlueprintList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.blueprint.models.PublishedBlueprintList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprintList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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("PublishedBlueprintList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/__init__.py new file mode 100644 index 000000000000..9c2008458439 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/__init__.py @@ -0,0 +1,121 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import Artifact +from ._models_py3 import ArtifactList +from ._models_py3 import ArtifactPropertiesBase +from ._models_py3 import Assignment +from ._models_py3 import AssignmentDeploymentJob +from ._models_py3 import AssignmentDeploymentJobResult +from ._models_py3 import AssignmentJobCreatedResource +from ._models_py3 import AssignmentList +from ._models_py3 import AssignmentLockSettings +from ._models_py3 import AssignmentOperation +from ._models_py3 import AssignmentOperationList +from ._models_py3 import AssignmentProperties +from ._models_py3 import AssignmentStatus +from ._models_py3 import AzureResourceBase +from ._models_py3 import AzureResourceManagerError +from ._models_py3 import Blueprint +from ._models_py3 import BlueprintList +from ._models_py3 import BlueprintProperties +from ._models_py3 import BlueprintResourcePropertiesBase +from ._models_py3 import BlueprintResourceStatusBase +from ._models_py3 import BlueprintStatus +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import KeyVaultReference +from ._models_py3 import ManagedServiceIdentity +from ._models_py3 import ParameterDefinition +from ._models_py3 import ParameterValue +from ._models_py3 import PolicyAssignmentArtifact +from ._models_py3 import PolicyAssignmentArtifactProperties +from ._models_py3 import PublishedBlueprint +from ._models_py3 import PublishedBlueprintList +from ._models_py3 import PublishedBlueprintProperties +from ._models_py3 import ResourceGroupDefinition +from ._models_py3 import ResourceGroupValue +from ._models_py3 import ResourceProviderOperation +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList +from ._models_py3 import RoleAssignmentArtifact +from ._models_py3 import RoleAssignmentArtifactProperties +from ._models_py3 import SecretValueReference +from ._models_py3 import SharedBlueprintProperties +from ._models_py3 import TemplateArtifact +from ._models_py3 import TemplateArtifactProperties +from ._models_py3 import TrackedResource +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import WhoIsBlueprintContract + + +from ._blueprint_management_client_enums import ( + ArtifactKind, + AssignmentDeleteBehavior, + AssignmentLockMode, + AssignmentProvisioningState, + BlueprintTargetScope, + ManagedServiceIdentityType, + TemplateParameterType, +) + +__all__ = [ + 'Artifact', + 'ArtifactList', + 'ArtifactPropertiesBase', + 'Assignment', + 'AssignmentDeploymentJob', + 'AssignmentDeploymentJobResult', + 'AssignmentJobCreatedResource', + 'AssignmentList', + 'AssignmentLockSettings', + 'AssignmentOperation', + 'AssignmentOperationList', + 'AssignmentProperties', + 'AssignmentStatus', + 'AzureResourceBase', + 'AzureResourceManagerError', + 'Blueprint', + 'BlueprintList', + 'BlueprintProperties', + 'BlueprintResourcePropertiesBase', + 'BlueprintResourceStatusBase', + 'BlueprintStatus', + 'ErrorAdditionalInfo', + 'ErrorResponse', + 'KeyVaultReference', + 'ManagedServiceIdentity', + 'ParameterDefinition', + 'ParameterValue', + 'PolicyAssignmentArtifact', + 'PolicyAssignmentArtifactProperties', + 'PublishedBlueprint', + 'PublishedBlueprintList', + 'PublishedBlueprintProperties', + 'ResourceGroupDefinition', + 'ResourceGroupValue', + 'ResourceProviderOperation', + 'ResourceProviderOperationDisplay', + 'ResourceProviderOperationList', + 'RoleAssignmentArtifact', + 'RoleAssignmentArtifactProperties', + 'SecretValueReference', + 'SharedBlueprintProperties', + 'TemplateArtifact', + 'TemplateArtifactProperties', + 'TrackedResource', + 'UserAssignedIdentity', + 'WhoIsBlueprintContract', + 'ArtifactKind', + 'AssignmentDeleteBehavior', + 'AssignmentLockMode', + 'AssignmentProvisioningState', + 'BlueprintTargetScope', + 'ManagedServiceIdentityType', + 'TemplateParameterType', +] diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_blueprint_management_client_enums.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_blueprint_management_client_enums.py new file mode 100644 index 000000000000..19a71d3c20d9 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_blueprint_management_client_enums.py @@ -0,0 +1,78 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 ArtifactKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the kind of blueprint artifact. + """ + + TEMPLATE = "template" + ROLE_ASSIGNMENT = "roleAssignment" + POLICY_ASSIGNMENT = "policyAssignment" + +class AssignmentDeleteBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + NONE = "none" + ALL = "all" + +class AssignmentLockMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Lock mode. + """ + + NONE = "None" + ALL_RESOURCES_READ_ONLY = "AllResourcesReadOnly" + ALL_RESOURCES_DO_NOT_DELETE = "AllResourcesDoNotDelete" + +class AssignmentProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """State of the blueprint assignment. + """ + + CREATING = "creating" + VALIDATING = "validating" + WAITING = "waiting" + DEPLOYING = "deploying" + CANCELLING = "cancelling" + LOCKING = "locking" + SUCCEEDED = "succeeded" + FAILED = "failed" + CANCELED = "canceled" + DELETING = "deleting" + +class BlueprintTargetScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The scope where this blueprint definition can be assigned. + """ + + #: The blueprint targets a subscription during blueprint assignment. + SUBSCRIPTION = "subscription" + #: The blueprint targets a management group during blueprint assignment. This is reserved for + #: future use. + MANAGEMENT_GROUP = "managementGroup" + +class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Type of the managed identity. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + +class TemplateParameterType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Allowed data types for Resource Manager template parameters. + """ + + STRING = "string" + ARRAY = "array" + BOOL = "bool" + INT = "int" + OBJECT = "object" + SECURE_OBJECT = "secureObject" + SECURE_STRING = "secureString" diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_models_py3.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_models_py3.py new file mode 100644 index 000000000000..59f5f49fa77e --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/models/_models_py3.py @@ -0,0 +1,2495 @@ +# 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, Dict, List, Optional, Union + +import msrest.serialization + +from ._blueprint_management_client_enums import * + + +class AzureResourceBase(msrest.serialization.Model): + """Common properties for all Azure resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AzureResourceBase, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + + +class Artifact(AzureResourceBase): + """Represents a blueprint artifact. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: PolicyAssignmentArtifact, RoleAssignmentArtifact, TemplateArtifact. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar kind: Required. Specifies the kind of blueprint artifact.Constant filled by server. + Possible values include: "template", "roleAssignment", "policyAssignment". + :vartype kind: str or ~azure.mgmt.blueprint.models.ArtifactKind + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + } + + _subtype_map = { + 'kind': {'policyAssignment': 'PolicyAssignmentArtifact', 'roleAssignment': 'RoleAssignmentArtifact', 'template': 'TemplateArtifact'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Artifact, self).__init__(**kwargs) + self.kind = 'Artifact' # type: str + + +class ArtifactList(msrest.serialization.Model): + """List of blueprint artifacts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blueprint artifacts. + :vartype value: list[~azure.mgmt.blueprint.models.Artifact] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Artifact]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Artifact"]] = None, + **kwargs + ): + """ + :keyword value: List of blueprint artifacts. + :paramtype value: list[~azure.mgmt.blueprint.models.Artifact] + """ + super(ArtifactList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ArtifactPropertiesBase(msrest.serialization.Model): + """Common properties shared by different artifacts. + + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + """ + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, + } + + def __init__( + self, + *, + depends_on: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + """ + super(ArtifactPropertiesBase, self).__init__(**kwargs) + self.depends_on = depends_on + + +class TrackedResource(AzureResourceBase): + """Common properties for all Azure tracked resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar location: Required. The location of this blueprint assignment. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + **kwargs + ): + """ + :keyword location: Required. The location of this blueprint assignment. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.location = location + + +class Assignment(TrackedResource): + """Represents a blueprint assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar location: Required. The location of this blueprint assignment. + :vartype location: str + :ivar identity: Required. Managed identity for this blueprint assignment. + :vartype identity: ~azure.mgmt.blueprint.models.ManagedServiceIdentity + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar blueprint_id: ID of the published version of a blueprint definition. + :vartype blueprint_id: str + :ivar scope: The target subscription scope of the blueprint assignment (format: + '/subscriptions/{subscriptionId}'). For management group level assignments, the property is + required. + :vartype scope: str + :ivar parameters: Required. Blueprint assignment parameter values. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :ivar resource_groups: Required. Names and locations of resource group placeholders. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupValue] + :ivar status: Status of blueprint assignment. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.AssignmentStatus + :ivar locks: Defines how resources deployed by a blueprint assignment are locked. + :vartype locks: ~azure.mgmt.blueprint.models.AssignmentLockSettings + :ivar provisioning_state: State of the blueprint assignment. Possible values include: + "creating", "validating", "waiting", "deploying", "cancelling", "locking", "succeeded", + "failed", "canceled", "deleting". + :vartype provisioning_state: str or ~azure.mgmt.blueprint.models.AssignmentProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'location': {'required': True}, + 'identity': {'required': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'parameters': {'required': True}, + 'resource_groups': {'required': True}, + 'status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'blueprint_id': {'key': 'properties.blueprintId', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValue}'}, + 'resource_groups': {'key': 'properties.resourceGroups', 'type': '{ResourceGroupValue}'}, + 'status': {'key': 'properties.status', 'type': 'AssignmentStatus'}, + 'locks': {'key': 'properties.locks', 'type': 'AssignmentLockSettings'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + identity: "ManagedServiceIdentity", + parameters: Dict[str, "ParameterValue"], + resource_groups: Dict[str, "ResourceGroupValue"], + display_name: Optional[str] = None, + description: Optional[str] = None, + blueprint_id: Optional[str] = None, + scope: Optional[str] = None, + locks: Optional["AssignmentLockSettings"] = None, + **kwargs + ): + """ + :keyword location: Required. The location of this blueprint assignment. + :paramtype location: str + :keyword identity: Required. Managed identity for this blueprint assignment. + :paramtype identity: ~azure.mgmt.blueprint.models.ManagedServiceIdentity + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword blueprint_id: ID of the published version of a blueprint definition. + :paramtype blueprint_id: str + :keyword scope: The target subscription scope of the blueprint assignment (format: + '/subscriptions/{subscriptionId}'). For management group level assignments, the property is + required. + :paramtype scope: str + :keyword parameters: Required. Blueprint assignment parameter values. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :keyword resource_groups: Required. Names and locations of resource group placeholders. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupValue] + :keyword locks: Defines how resources deployed by a blueprint assignment are locked. + :paramtype locks: ~azure.mgmt.blueprint.models.AssignmentLockSettings + """ + super(Assignment, self).__init__(location=location, **kwargs) + self.identity = identity + self.display_name = display_name + self.description = description + self.blueprint_id = blueprint_id + self.scope = scope + self.parameters = parameters + self.resource_groups = resource_groups + self.status = None + self.locks = locks + self.provisioning_state = None + + +class AssignmentDeploymentJob(msrest.serialization.Model): + """Represents individual job in given blueprint assignment operation. + + :ivar kind: Kind of job. + :vartype kind: str + :ivar action: Name of the action performed in this job. + :vartype action: str + :ivar job_id: Id of this job. + :vartype job_id: str + :ivar job_state: State of this job. + :vartype job_state: str + :ivar result: Deployment job result. + :vartype result: ~azure.mgmt.blueprint.models.AssignmentDeploymentJobResult + :ivar history: Result of this deployment job for each retry. + :vartype history: list[~azure.mgmt.blueprint.models.AssignmentDeploymentJobResult] + :ivar request_uri: Reference to deployment job resource id. + :vartype request_uri: str + """ + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + 'job_id': {'key': 'jobId', 'type': 'str'}, + 'job_state': {'key': 'jobState', 'type': 'str'}, + 'result': {'key': 'result', 'type': 'AssignmentDeploymentJobResult'}, + 'history': {'key': 'history', 'type': '[AssignmentDeploymentJobResult]'}, + 'request_uri': {'key': 'requestUri', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: Optional[str] = None, + action: Optional[str] = None, + job_id: Optional[str] = None, + job_state: Optional[str] = None, + result: Optional["AssignmentDeploymentJobResult"] = None, + history: Optional[List["AssignmentDeploymentJobResult"]] = None, + request_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword kind: Kind of job. + :paramtype kind: str + :keyword action: Name of the action performed in this job. + :paramtype action: str + :keyword job_id: Id of this job. + :paramtype job_id: str + :keyword job_state: State of this job. + :paramtype job_state: str + :keyword result: Deployment job result. + :paramtype result: ~azure.mgmt.blueprint.models.AssignmentDeploymentJobResult + :keyword history: Result of this deployment job for each retry. + :paramtype history: list[~azure.mgmt.blueprint.models.AssignmentDeploymentJobResult] + :keyword request_uri: Reference to deployment job resource id. + :paramtype request_uri: str + """ + super(AssignmentDeploymentJob, self).__init__(**kwargs) + self.kind = kind + self.action = action + self.job_id = job_id + self.job_state = job_state + self.result = result + self.history = history + self.request_uri = request_uri + + +class AssignmentDeploymentJobResult(msrest.serialization.Model): + """Result of each individual deployment in a blueprint assignment. + + :ivar error: Contains error details if deployment job failed. + :vartype error: ~azure.mgmt.blueprint.models.AzureResourceManagerError + :ivar resources: Resources created as result of the deployment job. + :vartype resources: list[~azure.mgmt.blueprint.models.AssignmentJobCreatedResource] + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'AzureResourceManagerError'}, + 'resources': {'key': 'resources', 'type': '[AssignmentJobCreatedResource]'}, + } + + def __init__( + self, + *, + error: Optional["AzureResourceManagerError"] = None, + resources: Optional[List["AssignmentJobCreatedResource"]] = None, + **kwargs + ): + """ + :keyword error: Contains error details if deployment job failed. + :paramtype error: ~azure.mgmt.blueprint.models.AzureResourceManagerError + :keyword resources: Resources created as result of the deployment job. + :paramtype resources: list[~azure.mgmt.blueprint.models.AssignmentJobCreatedResource] + """ + super(AssignmentDeploymentJobResult, self).__init__(**kwargs) + self.error = error + self.resources = resources + + +class AssignmentJobCreatedResource(AzureResourceBase): + """Azure resource created from deployment job. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar properties: Additional properties in a dictionary. + :vartype properties: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{str}'}, + } + + def __init__( + self, + *, + properties: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword properties: Additional properties in a dictionary. + :paramtype properties: dict[str, str] + """ + super(AssignmentJobCreatedResource, self).__init__(**kwargs) + self.properties = properties + + +class AssignmentList(msrest.serialization.Model): + """List of blueprint assignments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blueprint assignments. + :vartype value: list[~azure.mgmt.blueprint.models.Assignment] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Assignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Assignment"]] = None, + **kwargs + ): + """ + :keyword value: List of blueprint assignments. + :paramtype value: list[~azure.mgmt.blueprint.models.Assignment] + """ + super(AssignmentList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class AssignmentLockSettings(msrest.serialization.Model): + """Defines how resources deployed by a blueprint assignment are locked. + + :ivar mode: Lock mode. Possible values include: "None", "AllResourcesReadOnly", + "AllResourcesDoNotDelete". + :vartype mode: str or ~azure.mgmt.blueprint.models.AssignmentLockMode + :ivar excluded_principals: List of AAD principals excluded from blueprint locks. Up to 5 + principals are permitted. + :vartype excluded_principals: list[str] + :ivar excluded_actions: + List of management operations that are excluded from blueprint locks. Up to 200 actions are permitted. + If the lock mode is set to 'AllResourcesReadOnly', then the following actions are automatically + appended to 'excludedActions': '*/read', + 'Microsoft.Network/virtualNetworks/subnets/join/action' and + 'Microsoft.Authorization/locks/delete'. If the lock mode is set to 'AllResourcesDoNotDelete', + then the following actions are automatically appended to 'excludedActions': + 'Microsoft.Authorization/locks/delete'. Duplicate actions will get removed. + :vartype excluded_actions: list[str] + """ + + _attribute_map = { + 'mode': {'key': 'mode', 'type': 'str'}, + 'excluded_principals': {'key': 'excludedPrincipals', 'type': '[str]'}, + 'excluded_actions': {'key': 'excludedActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + mode: Optional[Union[str, "AssignmentLockMode"]] = None, + excluded_principals: Optional[List[str]] = None, + excluded_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword mode: Lock mode. Possible values include: "None", "AllResourcesReadOnly", + "AllResourcesDoNotDelete". + :paramtype mode: str or ~azure.mgmt.blueprint.models.AssignmentLockMode + :keyword excluded_principals: List of AAD principals excluded from blueprint locks. Up to 5 + principals are permitted. + :paramtype excluded_principals: list[str] + :keyword excluded_actions: + List of management operations that are excluded from blueprint locks. Up to 200 actions are permitted. + If the lock mode is set to 'AllResourcesReadOnly', then the following actions are automatically + appended to 'excludedActions': '*/read', + 'Microsoft.Network/virtualNetworks/subnets/join/action' and + 'Microsoft.Authorization/locks/delete'. If the lock mode is set to 'AllResourcesDoNotDelete', + then the following actions are automatically appended to 'excludedActions': + 'Microsoft.Authorization/locks/delete'. Duplicate actions will get removed. + :paramtype excluded_actions: list[str] + """ + super(AssignmentLockSettings, self).__init__(**kwargs) + self.mode = mode + self.excluded_principals = excluded_principals + self.excluded_actions = excluded_actions + + +class AssignmentOperation(AzureResourceBase): + """Represents underlying deployment detail for each update to the blueprint assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar blueprint_version: The published version of the blueprint definition used for the + blueprint assignment operation. + :vartype blueprint_version: str + :ivar assignment_state: State of this blueprint assignment operation. + :vartype assignment_state: str + :ivar time_created: Create time of this blueprint assignment operation. + :vartype time_created: str + :ivar time_started: Start time of the underlying deployment. + :vartype time_started: str + :ivar time_finished: Finish time of the overall underlying deployments. + :vartype time_finished: str + :ivar deployments: List of jobs in this blueprint assignment operation. + :vartype deployments: list[~azure.mgmt.blueprint.models.AssignmentDeploymentJob] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'blueprint_version': {'key': 'properties.blueprintVersion', 'type': 'str'}, + 'assignment_state': {'key': 'properties.assignmentState', 'type': 'str'}, + 'time_created': {'key': 'properties.timeCreated', 'type': 'str'}, + 'time_started': {'key': 'properties.timeStarted', 'type': 'str'}, + 'time_finished': {'key': 'properties.timeFinished', 'type': 'str'}, + 'deployments': {'key': 'properties.deployments', 'type': '[AssignmentDeploymentJob]'}, + } + + def __init__( + self, + *, + blueprint_version: Optional[str] = None, + assignment_state: Optional[str] = None, + time_created: Optional[str] = None, + time_started: Optional[str] = None, + time_finished: Optional[str] = None, + deployments: Optional[List["AssignmentDeploymentJob"]] = None, + **kwargs + ): + """ + :keyword blueprint_version: The published version of the blueprint definition used for the + blueprint assignment operation. + :paramtype blueprint_version: str + :keyword assignment_state: State of this blueprint assignment operation. + :paramtype assignment_state: str + :keyword time_created: Create time of this blueprint assignment operation. + :paramtype time_created: str + :keyword time_started: Start time of the underlying deployment. + :paramtype time_started: str + :keyword time_finished: Finish time of the overall underlying deployments. + :paramtype time_finished: str + :keyword deployments: List of jobs in this blueprint assignment operation. + :paramtype deployments: list[~azure.mgmt.blueprint.models.AssignmentDeploymentJob] + """ + super(AssignmentOperation, self).__init__(**kwargs) + self.blueprint_version = blueprint_version + self.assignment_state = assignment_state + self.time_created = time_created + self.time_started = time_started + self.time_finished = time_finished + self.deployments = deployments + + +class AssignmentOperationList(msrest.serialization.Model): + """List of AssignmentOperation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of AssignmentOperation. + :vartype value: list[~azure.mgmt.blueprint.models.AssignmentOperation] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AssignmentOperation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AssignmentOperation"]] = None, + **kwargs + ): + """ + :keyword value: List of AssignmentOperation. + :paramtype value: list[~azure.mgmt.blueprint.models.AssignmentOperation] + """ + super(AssignmentOperationList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class BlueprintResourcePropertiesBase(msrest.serialization.Model): + """Shared properties between all blueprint resources. + + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + """ + super(BlueprintResourcePropertiesBase, self).__init__(**kwargs) + self.display_name = display_name + self.description = description + + +class AssignmentProperties(BlueprintResourcePropertiesBase): + """Detailed properties for a blueprint assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar blueprint_id: ID of the published version of a blueprint definition. + :vartype blueprint_id: str + :ivar scope: The target subscription scope of the blueprint assignment (format: + '/subscriptions/{subscriptionId}'). For management group level assignments, the property is + required. + :vartype scope: str + :ivar parameters: Required. Blueprint assignment parameter values. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :ivar resource_groups: Required. Names and locations of resource group placeholders. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupValue] + :ivar status: Status of blueprint assignment. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.AssignmentStatus + :ivar locks: Defines how resources deployed by a blueprint assignment are locked. + :vartype locks: ~azure.mgmt.blueprint.models.AssignmentLockSettings + :ivar provisioning_state: State of the blueprint assignment. Possible values include: + "creating", "validating", "waiting", "deploying", "cancelling", "locking", "succeeded", + "failed", "canceled", "deleting". + :vartype provisioning_state: str or ~azure.mgmt.blueprint.models.AssignmentProvisioningState + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'parameters': {'required': True}, + 'resource_groups': {'required': True}, + 'status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'blueprint_id': {'key': 'blueprintId', 'type': 'str'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterValue}'}, + 'resource_groups': {'key': 'resourceGroups', 'type': '{ResourceGroupValue}'}, + 'status': {'key': 'status', 'type': 'AssignmentStatus'}, + 'locks': {'key': 'locks', 'type': 'AssignmentLockSettings'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + parameters: Dict[str, "ParameterValue"], + resource_groups: Dict[str, "ResourceGroupValue"], + display_name: Optional[str] = None, + description: Optional[str] = None, + blueprint_id: Optional[str] = None, + scope: Optional[str] = None, + locks: Optional["AssignmentLockSettings"] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword blueprint_id: ID of the published version of a blueprint definition. + :paramtype blueprint_id: str + :keyword scope: The target subscription scope of the blueprint assignment (format: + '/subscriptions/{subscriptionId}'). For management group level assignments, the property is + required. + :paramtype scope: str + :keyword parameters: Required. Blueprint assignment parameter values. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :keyword resource_groups: Required. Names and locations of resource group placeholders. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupValue] + :keyword locks: Defines how resources deployed by a blueprint assignment are locked. + :paramtype locks: ~azure.mgmt.blueprint.models.AssignmentLockSettings + """ + super(AssignmentProperties, self).__init__(display_name=display_name, description=description, **kwargs) + self.blueprint_id = blueprint_id + self.scope = scope + self.parameters = parameters + self.resource_groups = resource_groups + self.status = None + self.locks = locks + self.provisioning_state = None + + +class BlueprintResourceStatusBase(msrest.serialization.Model): + """Shared status properties between all blueprint resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar time_created: Creation time of this blueprint definition. + :vartype time_created: ~datetime.datetime + :ivar last_modified: Last modified time of this blueprint definition. + :vartype last_modified: ~datetime.datetime + """ + + _validation = { + 'time_created': {'readonly': True}, + 'last_modified': {'readonly': True}, + } + + _attribute_map = { + 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, + 'last_modified': {'key': 'lastModified', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(BlueprintResourceStatusBase, self).__init__(**kwargs) + self.time_created = None + self.last_modified = None + + +class AssignmentStatus(BlueprintResourceStatusBase): + """The status of a blueprint assignment. This field is readonly. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar time_created: Creation time of this blueprint definition. + :vartype time_created: ~datetime.datetime + :ivar last_modified: Last modified time of this blueprint definition. + :vartype last_modified: ~datetime.datetime + :ivar managed_resources: List of resources that were created by the blueprint assignment. + :vartype managed_resources: list[str] + """ + + _validation = { + 'time_created': {'readonly': True}, + 'last_modified': {'readonly': True}, + 'managed_resources': {'readonly': True}, + } + + _attribute_map = { + 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, + 'last_modified': {'key': 'lastModified', 'type': 'iso-8601'}, + 'managed_resources': {'key': 'managedResources', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AssignmentStatus, self).__init__(**kwargs) + self.managed_resources = None + + +class AzureResourceManagerError(msrest.serialization.Model): + """Error code and message. + + :ivar code: Error code. + :vartype code: str + :ivar message: Error message. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message. + :paramtype message: str + """ + super(AzureResourceManagerError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class Blueprint(AzureResourceBase): + """Represents a Blueprint definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar status: Status of the blueprint. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.BlueprintStatus + :ivar target_scope: The scope where this blueprint definition can be assigned. Possible values + include: "subscription", "managementGroup". + :vartype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :ivar parameters: Parameters required by this blueprint definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :ivar resource_groups: Resource group placeholders defined by this blueprint definition. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :ivar versions: Published versions of this blueprint definition. + :vartype versions: any + :ivar layout: Layout view of the blueprint definition for UI reference. + :vartype layout: any + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'status': {'readonly': True}, + 'layout': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'BlueprintStatus'}, + 'target_scope': {'key': 'properties.targetScope', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinition}'}, + 'resource_groups': {'key': 'properties.resourceGroups', 'type': '{ResourceGroupDefinition}'}, + 'versions': {'key': 'properties.versions', 'type': 'object'}, + 'layout': {'key': 'properties.layout', 'type': 'object'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + target_scope: Optional[Union[str, "BlueprintTargetScope"]] = None, + parameters: Optional[Dict[str, "ParameterDefinition"]] = None, + resource_groups: Optional[Dict[str, "ResourceGroupDefinition"]] = None, + versions: Optional[Any] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword target_scope: The scope where this blueprint definition can be assigned. Possible + values include: "subscription", "managementGroup". + :paramtype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :keyword parameters: Parameters required by this blueprint definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :keyword resource_groups: Resource group placeholders defined by this blueprint definition. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :keyword versions: Published versions of this blueprint definition. + :paramtype versions: any + """ + super(Blueprint, self).__init__(**kwargs) + self.display_name = display_name + self.description = description + self.status = None + self.target_scope = target_scope + self.parameters = parameters + self.resource_groups = resource_groups + self.versions = versions + self.layout = None + + +class BlueprintList(msrest.serialization.Model): + """List of blueprint definitions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blueprint definitions. + :vartype value: list[~azure.mgmt.blueprint.models.Blueprint] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Blueprint]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Blueprint"]] = None, + **kwargs + ): + """ + :keyword value: List of blueprint definitions. + :paramtype value: list[~azure.mgmt.blueprint.models.Blueprint] + """ + super(BlueprintList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class SharedBlueprintProperties(BlueprintResourcePropertiesBase): + """Shared Schema for both blueprintProperties and publishedBlueprintProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar status: Status of the blueprint. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.BlueprintStatus + :ivar target_scope: The scope where this blueprint definition can be assigned. Possible values + include: "subscription", "managementGroup". + :vartype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :ivar parameters: Parameters required by this blueprint definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :ivar resource_groups: Resource group placeholders defined by this blueprint definition. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'status': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'BlueprintStatus'}, + 'target_scope': {'key': 'targetScope', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterDefinition}'}, + 'resource_groups': {'key': 'resourceGroups', 'type': '{ResourceGroupDefinition}'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + target_scope: Optional[Union[str, "BlueprintTargetScope"]] = None, + parameters: Optional[Dict[str, "ParameterDefinition"]] = None, + resource_groups: Optional[Dict[str, "ResourceGroupDefinition"]] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword target_scope: The scope where this blueprint definition can be assigned. Possible + values include: "subscription", "managementGroup". + :paramtype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :keyword parameters: Parameters required by this blueprint definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :keyword resource_groups: Resource group placeholders defined by this blueprint definition. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + """ + super(SharedBlueprintProperties, self).__init__(display_name=display_name, description=description, **kwargs) + self.status = None + self.target_scope = target_scope + self.parameters = parameters + self.resource_groups = resource_groups + + +class BlueprintProperties(SharedBlueprintProperties): + """Schema for blueprint definition properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar status: Status of the blueprint. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.BlueprintStatus + :ivar target_scope: The scope where this blueprint definition can be assigned. Possible values + include: "subscription", "managementGroup". + :vartype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :ivar parameters: Parameters required by this blueprint definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :ivar resource_groups: Resource group placeholders defined by this blueprint definition. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :ivar versions: Published versions of this blueprint definition. + :vartype versions: any + :ivar layout: Layout view of the blueprint definition for UI reference. + :vartype layout: any + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'status': {'readonly': True}, + 'layout': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'BlueprintStatus'}, + 'target_scope': {'key': 'targetScope', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterDefinition}'}, + 'resource_groups': {'key': 'resourceGroups', 'type': '{ResourceGroupDefinition}'}, + 'versions': {'key': 'versions', 'type': 'object'}, + 'layout': {'key': 'layout', 'type': 'object'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + target_scope: Optional[Union[str, "BlueprintTargetScope"]] = None, + parameters: Optional[Dict[str, "ParameterDefinition"]] = None, + resource_groups: Optional[Dict[str, "ResourceGroupDefinition"]] = None, + versions: Optional[Any] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword target_scope: The scope where this blueprint definition can be assigned. Possible + values include: "subscription", "managementGroup". + :paramtype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :keyword parameters: Parameters required by this blueprint definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :keyword resource_groups: Resource group placeholders defined by this blueprint definition. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :keyword versions: Published versions of this blueprint definition. + :paramtype versions: any + """ + super(BlueprintProperties, self).__init__(display_name=display_name, description=description, target_scope=target_scope, parameters=parameters, resource_groups=resource_groups, **kwargs) + self.versions = versions + self.layout = None + + +class BlueprintStatus(BlueprintResourceStatusBase): + """The status of the blueprint. This field is readonly. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar time_created: Creation time of this blueprint definition. + :vartype time_created: ~datetime.datetime + :ivar last_modified: Last modified time of this blueprint definition. + :vartype last_modified: ~datetime.datetime + """ + + _validation = { + 'time_created': {'readonly': True}, + 'last_modified': {'readonly': True}, + } + + _attribute_map = { + 'time_created': {'key': 'timeCreated', 'type': 'iso-8601'}, + 'last_modified': {'key': 'lastModified', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(BlueprintStatus, self).__init__(**kwargs) + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: any + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.blueprint.models.ErrorResponse] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.blueprint.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class KeyVaultReference(msrest.serialization.Model): + """Specifies the link to a Key Vault. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. Azure resource ID of the Key Vault. + :vartype id: str + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: str, + **kwargs + ): + """ + :keyword id: Required. Azure resource ID of the Key Vault. + :paramtype id: str + """ + super(KeyVaultReference, self).__init__(**kwargs) + self.id = id + + +class ManagedServiceIdentity(msrest.serialization.Model): + """Managed identity generic object. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. Type of the managed identity. Possible values include: "None", + "SystemAssigned", "UserAssigned". + :vartype type: str or ~azure.mgmt.blueprint.models.ManagedServiceIdentityType + :ivar principal_id: Azure Active Directory principal ID associated with this Identity. + :vartype principal_id: str + :ivar tenant_id: ID of the Azure Active Directory. + :vartype tenant_id: str + :ivar user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.blueprint.models.UserAssignedIdentity] + """ + + _validation = { + 'type': {'required': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + } + + def __init__( + self, + *, + type: Union[str, "ManagedServiceIdentityType"], + principal_id: Optional[str] = None, + tenant_id: Optional[str] = None, + user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: Required. Type of the managed identity. Possible values include: "None", + "SystemAssigned", "UserAssigned". + :paramtype type: str or ~azure.mgmt.blueprint.models.ManagedServiceIdentityType + :keyword principal_id: Azure Active Directory principal ID associated with this Identity. + :paramtype principal_id: str + :keyword tenant_id: ID of the Azure Active Directory. + :paramtype tenant_id: str + :keyword user_assigned_identities: The list of user-assigned managed identities associated with + the resource. Key is the Azure resource Id of the managed identity. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.blueprint.models.UserAssignedIdentity] + """ + super(ManagedServiceIdentity, self).__init__(**kwargs) + self.type = type + self.principal_id = principal_id + self.tenant_id = tenant_id + self.user_assigned_identities = user_assigned_identities + + +class ParameterDefinition(msrest.serialization.Model): + """Represent a parameter with constrains and metadata. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Required. Allowed data types for Resource Manager template parameters. Possible + values include: "string", "array", "bool", "int", "object", "secureObject", "secureString". + :vartype type: str or ~azure.mgmt.blueprint.models.TemplateParameterType + :ivar default_value: Default Value for this parameter. + :vartype default_value: any + :ivar allowed_values: Array of allowed values for this parameter. + :vartype allowed_values: list[any] + :ivar display_name: DisplayName of this parameter/resourceGroup. + :vartype display_name: str + :ivar description: Description of this parameter/resourceGroup. + :vartype description: str + :ivar strong_type: StrongType for UI to render rich experience during blueprint assignment. + Supported strong types are resourceType, principalId and location. + :vartype strong_type: str + """ + + _validation = { + 'type': {'required': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'strong_type': {'max_length': 64, 'min_length': 0}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'default_value': {'key': 'defaultValue', 'type': 'object'}, + 'allowed_values': {'key': 'allowedValues', 'type': '[object]'}, + 'display_name': {'key': 'metadata.displayName', 'type': 'str'}, + 'description': {'key': 'metadata.description', 'type': 'str'}, + 'strong_type': {'key': 'metadata.strongType', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Union[str, "TemplateParameterType"], + default_value: Optional[Any] = None, + allowed_values: Optional[List[Any]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + strong_type: Optional[str] = None, + **kwargs + ): + """ + :keyword type: Required. Allowed data types for Resource Manager template parameters. Possible + values include: "string", "array", "bool", "int", "object", "secureObject", "secureString". + :paramtype type: str or ~azure.mgmt.blueprint.models.TemplateParameterType + :keyword default_value: Default Value for this parameter. + :paramtype default_value: any + :keyword allowed_values: Array of allowed values for this parameter. + :paramtype allowed_values: list[any] + :keyword display_name: DisplayName of this parameter/resourceGroup. + :paramtype display_name: str + :keyword description: Description of this parameter/resourceGroup. + :paramtype description: str + :keyword strong_type: StrongType for UI to render rich experience during blueprint assignment. + Supported strong types are resourceType, principalId and location. + :paramtype strong_type: str + """ + super(ParameterDefinition, self).__init__(**kwargs) + self.type = type + self.default_value = default_value + self.allowed_values = allowed_values + self.display_name = display_name + self.description = description + self.strong_type = strong_type + + +class ParameterValue(msrest.serialization.Model): + """Value for the specified parameter. Can be either 'value' or 'reference' but not both. + + :ivar value: Parameter value. Any valid JSON value is allowed including objects, arrays, + strings, numbers and booleans. + :vartype value: any + :ivar reference: Parameter value as reference type. + :vartype reference: ~azure.mgmt.blueprint.models.SecretValueReference + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': 'object'}, + 'reference': {'key': 'reference', 'type': 'SecretValueReference'}, + } + + def __init__( + self, + *, + value: Optional[Any] = None, + reference: Optional["SecretValueReference"] = None, + **kwargs + ): + """ + :keyword value: Parameter value. Any valid JSON value is allowed including objects, arrays, + strings, numbers and booleans. + :paramtype value: any + :keyword reference: Parameter value as reference type. + :paramtype reference: ~azure.mgmt.blueprint.models.SecretValueReference + """ + super(ParameterValue, self).__init__(**kwargs) + self.value = value + self.reference = reference + + +class PolicyAssignmentArtifact(Artifact): + """Blueprint artifact that applies a Policy assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar kind: Required. Specifies the kind of blueprint artifact.Constant filled by server. + Possible values include: "template", "roleAssignment", "policyAssignment". + :vartype kind: str or ~azure.mgmt.blueprint.models.ArtifactKind + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar policy_definition_id: Required. Azure resource ID of the policy definition. + :vartype policy_definition_id: str + :ivar parameters: Required. Parameter values for the policy definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :ivar resource_group: Name of the resource group placeholder to which the policy will be + assigned. + :vartype resource_group: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'policy_definition_id': {'required': True}, + 'parameters': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'depends_on': {'key': 'properties.dependsOn', 'type': '[str]'}, + 'policy_definition_id': {'key': 'properties.policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValue}'}, + 'resource_group': {'key': 'properties.resourceGroup', 'type': 'str'}, + } + + def __init__( + self, + *, + policy_definition_id: str, + parameters: Dict[str, "ParameterValue"], + display_name: Optional[str] = None, + description: Optional[str] = None, + depends_on: Optional[List[str]] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword policy_definition_id: Required. Azure resource ID of the policy definition. + :paramtype policy_definition_id: str + :keyword parameters: Required. Parameter values for the policy definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :keyword resource_group: Name of the resource group placeholder to which the policy will be + assigned. + :paramtype resource_group: str + """ + super(PolicyAssignmentArtifact, self).__init__(**kwargs) + self.kind = 'policyAssignment' # type: str + self.display_name = display_name + self.description = description + self.depends_on = depends_on + self.policy_definition_id = policy_definition_id + self.parameters = parameters + self.resource_group = resource_group + + +class PolicyAssignmentArtifactProperties(BlueprintResourcePropertiesBase, ArtifactPropertiesBase): + """Properties of a Policy assignment blueprint artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar policy_definition_id: Required. Azure resource ID of the policy definition. + :vartype policy_definition_id: str + :ivar parameters: Required. Parameter values for the policy definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :ivar resource_group: Name of the resource group placeholder to which the policy will be + assigned. + :vartype resource_group: str + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'policy_definition_id': {'required': True}, + 'parameters': {'required': True}, + } + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterValue}'}, + 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + } + + def __init__( + self, + *, + policy_definition_id: str, + parameters: Dict[str, "ParameterValue"], + depends_on: Optional[List[str]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword policy_definition_id: Required. Azure resource ID of the policy definition. + :paramtype policy_definition_id: str + :keyword parameters: Required. Parameter values for the policy definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + :keyword resource_group: Name of the resource group placeholder to which the policy will be + assigned. + :paramtype resource_group: str + """ + super(PolicyAssignmentArtifactProperties, self).__init__(display_name=display_name, description=description, depends_on=depends_on, **kwargs) + self.depends_on = depends_on + self.policy_definition_id = policy_definition_id + self.parameters = parameters + self.resource_group = resource_group + self.display_name = display_name + self.description = description + self.policy_definition_id = policy_definition_id + self.parameters = parameters + self.resource_group = resource_group + + +class PublishedBlueprint(AzureResourceBase): + """Represents a published blueprint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar status: Status of the blueprint. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.BlueprintStatus + :ivar target_scope: The scope where this blueprint definition can be assigned. Possible values + include: "subscription", "managementGroup". + :vartype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :ivar parameters: Parameters required by this blueprint definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :ivar resource_groups: Resource group placeholders defined by this blueprint definition. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :ivar blueprint_name: Name of the published blueprint definition. + :vartype blueprint_name: str + :ivar change_notes: Version-specific change notes. + :vartype change_notes: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'status': {'readonly': True}, + 'change_notes': {'max_length': 500, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'BlueprintStatus'}, + 'target_scope': {'key': 'properties.targetScope', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterDefinition}'}, + 'resource_groups': {'key': 'properties.resourceGroups', 'type': '{ResourceGroupDefinition}'}, + 'blueprint_name': {'key': 'properties.blueprintName', 'type': 'str'}, + 'change_notes': {'key': 'properties.changeNotes', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + target_scope: Optional[Union[str, "BlueprintTargetScope"]] = None, + parameters: Optional[Dict[str, "ParameterDefinition"]] = None, + resource_groups: Optional[Dict[str, "ResourceGroupDefinition"]] = None, + blueprint_name: Optional[str] = None, + change_notes: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword target_scope: The scope where this blueprint definition can be assigned. Possible + values include: "subscription", "managementGroup". + :paramtype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :keyword parameters: Parameters required by this blueprint definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :keyword resource_groups: Resource group placeholders defined by this blueprint definition. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :keyword blueprint_name: Name of the published blueprint definition. + :paramtype blueprint_name: str + :keyword change_notes: Version-specific change notes. + :paramtype change_notes: str + """ + super(PublishedBlueprint, self).__init__(**kwargs) + self.display_name = display_name + self.description = description + self.status = None + self.target_scope = target_scope + self.parameters = parameters + self.resource_groups = resource_groups + self.blueprint_name = blueprint_name + self.change_notes = change_notes + + +class PublishedBlueprintList(msrest.serialization.Model): + """List of published blueprint definitions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of published blueprint definitions. + :vartype value: list[~azure.mgmt.blueprint.models.PublishedBlueprint] + :ivar next_link: Link to the next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PublishedBlueprint]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["PublishedBlueprint"]] = None, + **kwargs + ): + """ + :keyword value: List of published blueprint definitions. + :paramtype value: list[~azure.mgmt.blueprint.models.PublishedBlueprint] + """ + super(PublishedBlueprintList, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class PublishedBlueprintProperties(SharedBlueprintProperties): + """Schema for published blueprint definition properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar status: Status of the blueprint. This field is readonly. + :vartype status: ~azure.mgmt.blueprint.models.BlueprintStatus + :ivar target_scope: The scope where this blueprint definition can be assigned. Possible values + include: "subscription", "managementGroup". + :vartype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :ivar parameters: Parameters required by this blueprint definition. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :ivar resource_groups: Resource group placeholders defined by this blueprint definition. + :vartype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :ivar blueprint_name: Name of the published blueprint definition. + :vartype blueprint_name: str + :ivar change_notes: Version-specific change notes. + :vartype change_notes: str + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'status': {'readonly': True}, + 'change_notes': {'max_length': 500, 'min_length': 0}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'BlueprintStatus'}, + 'target_scope': {'key': 'targetScope', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterDefinition}'}, + 'resource_groups': {'key': 'resourceGroups', 'type': '{ResourceGroupDefinition}'}, + 'blueprint_name': {'key': 'blueprintName', 'type': 'str'}, + 'change_notes': {'key': 'changeNotes', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description: Optional[str] = None, + target_scope: Optional[Union[str, "BlueprintTargetScope"]] = None, + parameters: Optional[Dict[str, "ParameterDefinition"]] = None, + resource_groups: Optional[Dict[str, "ResourceGroupDefinition"]] = None, + blueprint_name: Optional[str] = None, + change_notes: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword target_scope: The scope where this blueprint definition can be assigned. Possible + values include: "subscription", "managementGroup". + :paramtype target_scope: str or ~azure.mgmt.blueprint.models.BlueprintTargetScope + :keyword parameters: Parameters required by this blueprint definition. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterDefinition] + :keyword resource_groups: Resource group placeholders defined by this blueprint definition. + :paramtype resource_groups: dict[str, ~azure.mgmt.blueprint.models.ResourceGroupDefinition] + :keyword blueprint_name: Name of the published blueprint definition. + :paramtype blueprint_name: str + :keyword change_notes: Version-specific change notes. + :paramtype change_notes: str + """ + super(PublishedBlueprintProperties, self).__init__(display_name=display_name, description=description, target_scope=target_scope, parameters=parameters, resource_groups=resource_groups, **kwargs) + self.blueprint_name = blueprint_name + self.change_notes = change_notes + + +class ResourceGroupDefinition(msrest.serialization.Model): + """Represents an Azure resource group in a blueprint definition. + + :ivar name: Name of this resourceGroup. Leave empty if the resource group name will be + specified during the blueprint assignment. + :vartype name: str + :ivar location: Location of this resourceGroup. Leave empty if the resource group location will + be specified during the blueprint assignment. + :vartype location: str + :ivar depends_on: Artifacts which need to be deployed before this resource group. + :vartype depends_on: list[str] + :ivar tags: A set of tags. Tags to be assigned to this resource group. + :vartype tags: dict[str, str] + :ivar display_name: DisplayName of this parameter/resourceGroup. + :vartype display_name: str + :ivar description: Description of this parameter/resourceGroup. + :vartype description: str + :ivar strong_type: StrongType for UI to render rich experience during blueprint assignment. + Supported strong types are resourceType, principalId and location. + :vartype strong_type: str + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'strong_type': {'max_length': 64, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'display_name': {'key': 'metadata.displayName', 'type': 'str'}, + 'description': {'key': 'metadata.description', 'type': 'str'}, + 'strong_type': {'key': 'metadata.strongType', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + location: Optional[str] = None, + depends_on: Optional[List[str]] = None, + tags: Optional[Dict[str, str]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + strong_type: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of this resourceGroup. Leave empty if the resource group name will be + specified during the blueprint assignment. + :paramtype name: str + :keyword location: Location of this resourceGroup. Leave empty if the resource group location + will be specified during the blueprint assignment. + :paramtype location: str + :keyword depends_on: Artifacts which need to be deployed before this resource group. + :paramtype depends_on: list[str] + :keyword tags: A set of tags. Tags to be assigned to this resource group. + :paramtype tags: dict[str, str] + :keyword display_name: DisplayName of this parameter/resourceGroup. + :paramtype display_name: str + :keyword description: Description of this parameter/resourceGroup. + :paramtype description: str + :keyword strong_type: StrongType for UI to render rich experience during blueprint assignment. + Supported strong types are resourceType, principalId and location. + :paramtype strong_type: str + """ + super(ResourceGroupDefinition, self).__init__(**kwargs) + self.name = name + self.location = location + self.depends_on = depends_on + self.tags = tags + self.display_name = display_name + self.description = description + self.strong_type = strong_type + + +class ResourceGroupValue(msrest.serialization.Model): + """Represents an Azure resource group. + + :ivar name: Name of the resource group. + :vartype name: str + :ivar location: Location of the resource group. + :vartype location: str + """ + + _validation = { + 'name': {'max_length': 90, 'min_length': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the resource group. + :paramtype name: str + :keyword location: Location of the resource group. + :paramtype location: str + """ + super(ResourceGroupValue, self).__init__(**kwargs) + self.name = name + self.location = location + + +class ResourceProviderOperation(msrest.serialization.Model): + """Supported operations of this resource provider. + + :ivar name: Operation name, in format of {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.blueprint.models.ResourceProviderOperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["ResourceProviderOperationDisplay"] = None, + **kwargs + ): + """ + :keyword name: Operation name, in format of {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.blueprint.models.ResourceProviderOperationDisplay + """ + super(ResourceProviderOperation, self).__init__(**kwargs) + self.name = name + self.display = display + + +class ResourceProviderOperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Resource provider: Microsoft Blueprint. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of this operation. + :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: Resource provider: Microsoft Blueprint. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of this operation. + :paramtype description: str + """ + super(ResourceProviderOperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class ResourceProviderOperationList(msrest.serialization.Model): + """Results of the request to list operations. + + :ivar value: List of operations supported by this resource provider. + :vartype value: list[~azure.mgmt.blueprint.models.ResourceProviderOperation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ResourceProviderOperation]'}, + } + + def __init__( + self, + *, + value: Optional[List["ResourceProviderOperation"]] = None, + **kwargs + ): + """ + :keyword value: List of operations supported by this resource provider. + :paramtype value: list[~azure.mgmt.blueprint.models.ResourceProviderOperation] + """ + super(ResourceProviderOperationList, self).__init__(**kwargs) + self.value = value + + +class RoleAssignmentArtifact(Artifact): + """Blueprint artifact that applies a Role assignment. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar kind: Required. Specifies the kind of blueprint artifact.Constant filled by server. + Possible values include: "template", "roleAssignment", "policyAssignment". + :vartype kind: str or ~azure.mgmt.blueprint.models.ArtifactKind + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar role_definition_id: Required. Azure resource ID of the RoleDefinition. + :vartype role_definition_id: str + :ivar principal_ids: Required. Array of user or group identities in Azure Active Directory. The + roleDefinition will apply to each identity. + :vartype principal_ids: any + :ivar resource_group: RoleAssignment will be scope to this resourceGroup. If empty, it scopes + to the subscription. + :vartype resource_group: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'role_definition_id': {'required': True}, + 'principal_ids': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'depends_on': {'key': 'properties.dependsOn', 'type': '[str]'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_ids': {'key': 'properties.principalIds', 'type': 'object'}, + 'resource_group': {'key': 'properties.resourceGroup', 'type': 'str'}, + } + + def __init__( + self, + *, + role_definition_id: str, + principal_ids: Any, + display_name: Optional[str] = None, + description: Optional[str] = None, + depends_on: Optional[List[str]] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword role_definition_id: Required. Azure resource ID of the RoleDefinition. + :paramtype role_definition_id: str + :keyword principal_ids: Required. Array of user or group identities in Azure Active Directory. + The roleDefinition will apply to each identity. + :paramtype principal_ids: any + :keyword resource_group: RoleAssignment will be scope to this resourceGroup. If empty, it + scopes to the subscription. + :paramtype resource_group: str + """ + super(RoleAssignmentArtifact, self).__init__(**kwargs) + self.kind = 'roleAssignment' # type: str + self.display_name = display_name + self.description = description + self.depends_on = depends_on + self.role_definition_id = role_definition_id + self.principal_ids = principal_ids + self.resource_group = resource_group + + +class RoleAssignmentArtifactProperties(BlueprintResourcePropertiesBase, ArtifactPropertiesBase): + """Properties of a Role assignment blueprint artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar role_definition_id: Required. Azure resource ID of the RoleDefinition. + :vartype role_definition_id: str + :ivar principal_ids: Required. Array of user or group identities in Azure Active Directory. The + roleDefinition will apply to each identity. + :vartype principal_ids: any + :ivar resource_group: RoleAssignment will be scope to this resourceGroup. If empty, it scopes + to the subscription. + :vartype resource_group: str + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'role_definition_id': {'required': True}, + 'principal_ids': {'required': True}, + } + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'principal_ids': {'key': 'principalIds', 'type': 'object'}, + 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + } + + def __init__( + self, + *, + role_definition_id: str, + principal_ids: Any, + depends_on: Optional[List[str]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword role_definition_id: Required. Azure resource ID of the RoleDefinition. + :paramtype role_definition_id: str + :keyword principal_ids: Required. Array of user or group identities in Azure Active Directory. + The roleDefinition will apply to each identity. + :paramtype principal_ids: any + :keyword resource_group: RoleAssignment will be scope to this resourceGroup. If empty, it + scopes to the subscription. + :paramtype resource_group: str + """ + super(RoleAssignmentArtifactProperties, self).__init__(display_name=display_name, description=description, depends_on=depends_on, **kwargs) + self.depends_on = depends_on + self.role_definition_id = role_definition_id + self.principal_ids = principal_ids + self.resource_group = resource_group + self.display_name = display_name + self.description = description + self.role_definition_id = role_definition_id + self.principal_ids = principal_ids + self.resource_group = resource_group + + +class SecretValueReference(msrest.serialization.Model): + """Reference to a Key Vault secret. + + All required parameters must be populated in order to send to Azure. + + :ivar key_vault: Required. Specifies the reference to a given Azure Key Vault. + :vartype key_vault: ~azure.mgmt.blueprint.models.KeyVaultReference + :ivar secret_name: Required. Name of the secret. + :vartype secret_name: str + :ivar secret_version: The version of the secret to use. If left blank, the latest version of + the secret is used. + :vartype secret_version: str + """ + + _validation = { + 'key_vault': {'required': True}, + 'secret_name': {'required': True}, + } + + _attribute_map = { + 'key_vault': {'key': 'keyVault', 'type': 'KeyVaultReference'}, + 'secret_name': {'key': 'secretName', 'type': 'str'}, + 'secret_version': {'key': 'secretVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + key_vault: "KeyVaultReference", + secret_name: str, + secret_version: Optional[str] = None, + **kwargs + ): + """ + :keyword key_vault: Required. Specifies the reference to a given Azure Key Vault. + :paramtype key_vault: ~azure.mgmt.blueprint.models.KeyVaultReference + :keyword secret_name: Required. Name of the secret. + :paramtype secret_name: str + :keyword secret_version: The version of the secret to use. If left blank, the latest version of + the secret is used. + :paramtype secret_version: str + """ + super(SecretValueReference, self).__init__(**kwargs) + self.key_vault = key_vault + self.secret_name = secret_name + self.secret_version = secret_version + + +class TemplateArtifact(Artifact): + """Blueprint artifact that deploys a Resource Manager template. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: String Id used to locate any resource on Azure. + :vartype id: str + :ivar type: Type of this resource. + :vartype type: str + :ivar name: Name of this resource. + :vartype name: str + :ivar kind: Required. Specifies the kind of blueprint artifact.Constant filled by server. + Possible values include: "template", "roleAssignment", "policyAssignment". + :vartype kind: str or ~azure.mgmt.blueprint.models.ArtifactKind + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar template: Required. The Resource Manager template blueprint artifact body. + :vartype template: any + :ivar resource_group: If applicable, the name of the resource group placeholder to which the + Resource Manager template blueprint artifact will be deployed. + :vartype resource_group: str + :ivar parameters: Required. Resource Manager template blueprint artifact parameter values. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'kind': {'required': True}, + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'template': {'required': True}, + 'parameters': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'depends_on': {'key': 'properties.dependsOn', 'type': '[str]'}, + 'template': {'key': 'properties.template', 'type': 'object'}, + 'resource_group': {'key': 'properties.resourceGroup', 'type': 'str'}, + 'parameters': {'key': 'properties.parameters', 'type': '{ParameterValue}'}, + } + + def __init__( + self, + *, + template: Any, + parameters: Dict[str, "ParameterValue"], + display_name: Optional[str] = None, + description: Optional[str] = None, + depends_on: Optional[List[str]] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword template: Required. The Resource Manager template blueprint artifact body. + :paramtype template: any + :keyword resource_group: If applicable, the name of the resource group placeholder to which the + Resource Manager template blueprint artifact will be deployed. + :paramtype resource_group: str + :keyword parameters: Required. Resource Manager template blueprint artifact parameter values. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + """ + super(TemplateArtifact, self).__init__(**kwargs) + self.kind = 'template' # type: str + self.display_name = display_name + self.description = description + self.depends_on = depends_on + self.template = template + self.resource_group = resource_group + self.parameters = parameters + + +class TemplateArtifactProperties(BlueprintResourcePropertiesBase, ArtifactPropertiesBase): + """Properties of a Resource Manager template blueprint artifact. + + All required parameters must be populated in order to send to Azure. + + :ivar depends_on: Artifacts which need to be deployed before the specified artifact. + :vartype depends_on: list[str] + :ivar display_name: One-liner string explain this resource. + :vartype display_name: str + :ivar description: Multi-line explain this resource. + :vartype description: str + :ivar template: Required. The Resource Manager template blueprint artifact body. + :vartype template: any + :ivar resource_group: If applicable, the name of the resource group placeholder to which the + Resource Manager template blueprint artifact will be deployed. + :vartype resource_group: str + :ivar parameters: Required. Resource Manager template blueprint artifact parameter values. + :vartype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + """ + + _validation = { + 'display_name': {'max_length': 256, 'min_length': 0}, + 'description': {'max_length': 500, 'min_length': 0}, + 'template': {'required': True}, + 'parameters': {'required': True}, + } + + _attribute_map = { + 'depends_on': {'key': 'dependsOn', 'type': '[str]'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'template': {'key': 'template', 'type': 'object'}, + 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '{ParameterValue}'}, + } + + def __init__( + self, + *, + template: Any, + parameters: Dict[str, "ParameterValue"], + depends_on: Optional[List[str]] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + resource_group: Optional[str] = None, + **kwargs + ): + """ + :keyword depends_on: Artifacts which need to be deployed before the specified artifact. + :paramtype depends_on: list[str] + :keyword display_name: One-liner string explain this resource. + :paramtype display_name: str + :keyword description: Multi-line explain this resource. + :paramtype description: str + :keyword template: Required. The Resource Manager template blueprint artifact body. + :paramtype template: any + :keyword resource_group: If applicable, the name of the resource group placeholder to which the + Resource Manager template blueprint artifact will be deployed. + :paramtype resource_group: str + :keyword parameters: Required. Resource Manager template blueprint artifact parameter values. + :paramtype parameters: dict[str, ~azure.mgmt.blueprint.models.ParameterValue] + """ + super(TemplateArtifactProperties, self).__init__(display_name=display_name, description=description, depends_on=depends_on, **kwargs) + self.depends_on = depends_on + self.template = template + self.resource_group = resource_group + self.parameters = parameters + self.display_name = display_name + self.description = description + self.template = template + self.resource_group = resource_group + self.parameters = parameters + + +class UserAssignedIdentity(msrest.serialization.Model): + """User-assigned managed identity. + + :ivar principal_id: Azure Active Directory principal ID associated with this Identity. + :vartype principal_id: str + :ivar client_id: Client App Id associated with this identity. + :vartype client_id: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + client_id: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Azure Active Directory principal ID associated with this Identity. + :paramtype principal_id: str + :keyword client_id: Client App Id associated with this identity. + :paramtype client_id: str + """ + super(UserAssignedIdentity, self).__init__(**kwargs) + self.principal_id = principal_id + self.client_id = client_id + + +class WhoIsBlueprintContract(msrest.serialization.Model): + """Response schema for querying the Azure Blueprints service principal in the tenant. + + :ivar object_id: AAD object Id of the Azure Blueprints service principal in the tenant. + :vartype object_id: str + """ + + _attribute_map = { + 'object_id': {'key': 'objectId', 'type': 'str'}, + } + + def __init__( + self, + *, + object_id: Optional[str] = None, + **kwargs + ): + """ + :keyword object_id: AAD object Id of the Azure Blueprints service principal in the tenant. + :paramtype object_id: str + """ + super(WhoIsBlueprintContract, self).__init__(**kwargs) + self.object_id = object_id diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/__init__.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/__init__.py new file mode 100644 index 000000000000..b5c4b8a1b2c2 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/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 ._blueprints_operations import BlueprintsOperations +from ._artifacts_operations import ArtifactsOperations +from ._published_blueprints_operations import PublishedBlueprintsOperations +from ._published_artifacts_operations import PublishedArtifactsOperations +from ._assignments_operations import AssignmentsOperations +from ._assignment_operations_operations import AssignmentOperationsOperations + +__all__ = [ + 'BlueprintsOperations', + 'ArtifactsOperations', + 'PublishedBlueprintsOperations', + 'PublishedArtifactsOperations', + 'AssignmentsOperations', + 'AssignmentOperationsOperations', +] diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_artifacts_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_artifacts_operations.py new file mode 100644 index 000000000000..b4e73347c552 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_artifacts_operations.py @@ -0,0 +1,447 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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, _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_create_or_update_request( + resource_scope: str, + blueprint_name: str, + artifact_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "artifactName": _SERIALIZER.url("artifact_name", artifact_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_get_request( + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "artifactName": _SERIALIZER.url("artifact_name", artifact_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_delete_request( + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "artifactName": _SERIALIZER.url("artifact_name", artifact_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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_scope: str, + blueprint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class ArtifactsOperations(object): + """ArtifactsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + artifact: "_models.Artifact", + **kwargs: Any + ) -> "_models.Artifact": + """Create or update blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :param artifact: Blueprint artifact to create or update. + :type artifact: ~azure.mgmt.blueprint.models.Artifact + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(artifact, 'Artifact') + + request = build_create_or_update_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any + ) -> "_models.Artifact": + """Get a blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_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('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_scope: str, + blueprint_name: str, + artifact_name: str, + **kwargs: Any + ) -> Optional["_models.Artifact"]: + """Delete a blueprint artifact. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Artifact"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + artifact_name=artifact_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> Iterable["_models.ArtifactList"]: + """List artifacts for a given blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArtifactList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.ArtifactList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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("ArtifactList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/artifacts'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignment_operations_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignment_operations_operations.py new file mode 100644 index 000000000000..8a85801c2818 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignment_operations_operations.py @@ -0,0 +1,246 @@ +# 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_scope: str, + assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_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_get_request( + resource_scope: str, + assignment_name: str, + assignment_operation_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations/{assignmentOperationName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_name, 'str'), + "assignmentOperationName": _SERIALIZER.url("assignment_operation_name", assignment_operation_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class AssignmentOperationsOperations(object): + """AssignmentOperationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> Iterable["_models.AssignmentOperationList"]: + """List operations for given blueprint assignment within a subscription or a management group. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssignmentOperationList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.AssignmentOperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentOperationList"] + 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( + resource_scope=resource_scope, + assignment_name=assignment_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + assignment_name=assignment_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("AssignmentOperationList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations'} # type: ignore + + @distributed_trace + def get( + self, + resource_scope: str, + assignment_name: str, + assignment_operation_name: str, + **kwargs: Any + ) -> "_models.AssignmentOperation": + """Get a blueprint assignment operation. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param assignment_operation_name: Name of the blueprint assignment operation. + :type assignment_operation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AssignmentOperation, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.AssignmentOperation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentOperation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + assignment_operation_name=assignment_operation_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('AssignmentOperation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/assignmentOperations/{assignmentOperationName}'} # type: ignore + diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignments_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignments_operations.py new file mode 100644 index 000000000000..de2e458b9dfb --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_assignments_operations.py @@ -0,0 +1,516 @@ +# 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.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_create_or_update_request( + resource_scope: str, + assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_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_get_request( + resource_scope: str, + assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_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_delete_request( + resource_scope: str, + assignment_name: str, + *, + delete_behavior: Optional[Union[str, "_models.AssignmentDeleteBehavior"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_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') + if delete_behavior is not None: + query_parameters['deleteBehavior'] = _SERIALIZER.query("delete_behavior", delete_behavior, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_who_is_blueprint_request( + resource_scope: str, + assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/whoIsBlueprint') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "assignmentName": _SERIALIZER.url("assignment_name", assignment_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_request( + resource_scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 AssignmentsOperations(object): + """AssignmentsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + assignment_name: str, + assignment: "_models.Assignment", + **kwargs: Any + ) -> "_models.Assignment": + """Create or update a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param assignment: Blueprint assignment object to save. + :type assignment: ~azure.mgmt.blueprint.models.Assignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Assignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(assignment, 'Assignment') + + request = build_create_or_update_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> "_models.Assignment": + """Get a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Assignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + assignment_name=assignment_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('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_scope: str, + assignment_name: str, + delete_behavior: Optional[Union[str, "_models.AssignmentDeleteBehavior"]] = None, + **kwargs: Any + ) -> Optional["_models.Assignment"]: + """Delete a blueprint assignment. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :param delete_behavior: When deleteBehavior=all, the resources that were created by the + blueprint assignment will be deleted. + :type delete_behavior: str or ~azure.mgmt.blueprint.models.AssignmentDeleteBehavior + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Assignment, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Assignment or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Assignment"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + delete_behavior=delete_behavior, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202, 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 == 202: + deserialized = self._deserialize('Assignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}'} # type: ignore + + + @distributed_trace + def who_is_blueprint( + self, + resource_scope: str, + assignment_name: str, + **kwargs: Any + ) -> "_models.WhoIsBlueprintContract": + """Get Blueprints service SPN objectId. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param assignment_name: Name of the blueprint assignment. + :type assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WhoIsBlueprintContract, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.WhoIsBlueprintContract + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.WhoIsBlueprintContract"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_who_is_blueprint_request( + resource_scope=resource_scope, + assignment_name=assignment_name, + template_url=self.who_is_blueprint.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('WhoIsBlueprintContract', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + who_is_blueprint.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments/{assignmentName}/whoIsBlueprint'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + **kwargs: Any + ) -> Iterable["_models.AssignmentList"]: + """List blueprint assignments within a subscription or a management group. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AssignmentList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.AssignmentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AssignmentList"] + 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( + resource_scope=resource_scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AssignmentList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprintAssignments'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_blueprints_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_blueprints_operations.py new file mode 100644 index 000000000000..3001e9863c8a --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_blueprints_operations.py @@ -0,0 +1,422 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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, _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_create_or_update_request( + resource_scope: str, + blueprint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_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_get_request( + resource_scope: str, + blueprint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_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_delete_request( + resource_scope: str, + blueprint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 BlueprintsOperations(object): + """BlueprintsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create_or_update( + self, + resource_scope: str, + blueprint_name: str, + blueprint: "_models.Blueprint", + **kwargs: Any + ) -> "_models.Blueprint": + """Create or update a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param blueprint: Blueprint definition. + :type blueprint: ~azure.mgmt.blueprint.models.Blueprint + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Blueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(blueprint, 'Blueprint') + + request = build_create_or_update_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> "_models.Blueprint": + """Get a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Blueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> Optional["_models.Blueprint"]: + """Delete a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Blueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Blueprint or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Blueprint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Blueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + **kwargs: Any + ) -> Iterable["_models.BlueprintList"]: + """List blueprint definitions. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlueprintList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.BlueprintList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.BlueprintList"] + 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( + resource_scope=resource_scope, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BlueprintList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_artifacts_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_artifacts_operations.py new file mode 100644 index 000000000000..1b670a9056e4 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_artifacts_operations.py @@ -0,0 +1,258 @@ +# 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_scope: str, + blueprint_name: str, + version_id: str, + artifact_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts/{artifactName}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "versionId": _SERIALIZER.url("version_id", version_id, 'str'), + "artifactName": _SERIALIZER.url("artifact_name", artifact_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_request( + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "versionId": _SERIALIZER.url("version_id", version_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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 PublishedArtifactsOperations(object): + """PublishedArtifactsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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, + resource_scope: str, + blueprint_name: str, + version_id: str, + artifact_name: str, + **kwargs: Any + ) -> "_models.Artifact": + """Get an artifact for a published blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :param artifact_name: Name of the blueprint artifact. + :type artifact_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Artifact, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.Artifact + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Artifact"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + artifact_name=artifact_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('Artifact', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts/{artifactName}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> Iterable["_models.ArtifactList"]: + """List artifacts for a version of a published blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ArtifactList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.ArtifactList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ArtifactList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_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("ArtifactList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}/artifacts'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_blueprints_operations.py b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_blueprints_operations.py new file mode 100644 index 000000000000..cb06c6e4e8d2 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/operations/_published_blueprints_operations.py @@ -0,0 +1,452 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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, _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_create_request( + resource_scope: str, + blueprint_name: str, + version_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "versionId": _SERIALIZER.url("version_id", version_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_get_request( + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "versionId": _SERIALIZER.url("version_id", version_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + "versionId": _SERIALIZER.url("version_id", version_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_scope: str, + blueprint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions') + path_format_arguments = { + "resourceScope": _SERIALIZER.url("resource_scope", resource_scope, 'str', skip_quote=True), + "blueprintName": _SERIALIZER.url("blueprint_name", blueprint_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class PublishedBlueprintsOperations(object): + """PublishedBlueprintsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.blueprint.models + :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 create( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + published_blueprint: Optional["_models.PublishedBlueprint"] = None, + **kwargs: Any + ) -> "_models.PublishedBlueprint": + """Publish a new version of the blueprint definition with the latest artifacts. Published + blueprint definitions are immutable. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :param published_blueprint: Published Blueprint to create or update. + :type published_blueprint: ~azure.mgmt.blueprint.models.PublishedBlueprint + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprint"] + 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 published_blueprint is not None: + _json = self._serialize.body(published_blueprint, 'PublishedBlueprint') + else: + _json = None + + request = build_create_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace + def get( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> "_models.PublishedBlueprint": + """Get a published version of a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprint"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_scope: str, + blueprint_name: str, + version_id: str, + **kwargs: Any + ) -> Optional["_models.PublishedBlueprint"]: + """Delete a published version of a blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :param version_id: Version of the published blueprint definition. + :type version_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PublishedBlueprint, or the result of cls(response) + :rtype: ~azure.mgmt.blueprint.models.PublishedBlueprint or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PublishedBlueprint"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + version_id=version_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('PublishedBlueprint', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions/{versionId}'} # type: ignore + + + @distributed_trace + def list( + self, + resource_scope: str, + blueprint_name: str, + **kwargs: Any + ) -> Iterable["_models.PublishedBlueprintList"]: + """List published versions of given blueprint definition. + + :param resource_scope: The scope of the resource. Valid scopes are: management group (format: + '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: + '/subscriptions/{subscriptionId}'). + :type resource_scope: str + :param blueprint_name: Name of the blueprint definition. + :type blueprint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PublishedBlueprintList or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.blueprint.models.PublishedBlueprintList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.PublishedBlueprintList"] + 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( + resource_scope=resource_scope, + blueprint_name=blueprint_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + resource_scope=resource_scope, + blueprint_name=blueprint_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("PublishedBlueprintList", 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': '/{resourceScope}/providers/Microsoft.Blueprint/blueprints/{blueprintName}/versions'} # type: ignore diff --git a/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/py.typed b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/azure/mgmt/blueprint/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/blueprint/azure-mgmt-blueprint/sdk_packaging.toml b/sdk/blueprint/azure-mgmt-blueprint/sdk_packaging.toml new file mode 100644 index 000000000000..631d1bbe1653 --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-blueprint" +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/blueprint/azure-mgmt-blueprint/setup.py b/sdk/blueprint/azure-mgmt-blueprint/setup.py new file mode 100644 index 000000000000..cface40aa74b --- /dev/null +++ b/sdk/blueprint/azure-mgmt-blueprint/setup.py @@ -0,0 +1,74 @@ +#!/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-blueprint" +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', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + 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/blueprint/ci.yml b/sdk/blueprint/ci.yml new file mode 100644 index 000000000000..b85a9e0c2598 --- /dev/null +++ b/sdk/blueprint/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/blueprint/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/blueprint/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: blueprint + Artifacts: + - name: azure-mgmt-blueprint + safeName: azuremgmtblueprint