diff --git a/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md b/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md new file mode 100644 index 000000000000..b410ddd059ae --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (2021-10-21) + +* Initial Release diff --git a/sdk/chaos/azure-mgmt-chaos/LICENSE.txt b/sdk/chaos/azure-mgmt-chaos/LICENSE.txt new file mode 100644 index 000000000000..2d3163745319 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +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/chaos/azure-mgmt-chaos/MANIFEST.in b/sdk/chaos/azure-mgmt-chaos/MANIFEST.in new file mode 100644 index 000000000000..ef61eb0e3527 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/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.txt diff --git a/sdk/chaos/azure-mgmt-chaos/README.md b/sdk/chaos/azure-mgmt-chaos/README.md new file mode 100644 index 000000000000..a4b87416a301 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Chaos Management Client Library. +This package has been tested with Python 2.7, 3.6+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# 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 [Chaos 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-chaos%2FREADME.png) diff --git a/sdk/chaos/azure-mgmt-chaos/_meta.json b/sdk/chaos/azure-mgmt-chaos/_meta.json new file mode 100644 index 000000000000..8c9f7f72e202 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.5", + "use": [ + "@autorest/python@5.8.4", + "@autorest/modelerfour@4.19.2" + ], + "commit": "ed12f5402e66c633320954bc4ca3494f267a4be3", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/chaos/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "readme": "specification/chaos/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/azure/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py new file mode 100644 index 000000000000..db6ceea94363 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_azure_chaos import MicrosoftAzureChaos +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MicrosoftAzureChaos'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py new file mode 100644 index 000000000000..4cae01768f94 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + + +class MicrosoftAzureChaosConfiguration(Configuration): + """Configuration for MicrosoftAzureChaos. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: GUID that represents an Azure subscription ID. + :type subscription_id: str + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftAzureChaosConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-09-15-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-chaos/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_metadata.json b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_metadata.json new file mode 100644 index 000000000000..c514182af54d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_metadata.json @@ -0,0 +1,108 @@ +{ + "chosen_version": "2021-09-15-preview", + "total_api_version_list": ["2021-09-15-preview"], + "client": { + "name": "MicrosoftAzureChaos", + "filename": "_microsoft_azure_chaos", + "description": "Azure Chaos Resource Provider REST API.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftAzureChaosConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftAzureChaosConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "GUID that represents an Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "GUID that represents an Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[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: Optional[str] = None,", + "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_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "capabilities": "CapabilitiesOperations", + "experiments": "ExperimentsOperations", + "operations": "Operations", + "targets": "TargetsOperations", + "target_types": "TargetTypesOperations", + "capability_types": "CapabilityTypesOperations" + } +} \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_microsoft_azure_chaos.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_microsoft_azure_chaos.py new file mode 100644 index 000000000000..8cb38ec211a1 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_microsoft_azure_chaos.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse + +from ._configuration import MicrosoftAzureChaosConfiguration +from .operations import CapabilitiesOperations +from .operations import ExperimentsOperations +from .operations import Operations +from .operations import TargetsOperations +from .operations import TargetTypesOperations +from .operations import CapabilityTypesOperations +from . import models + + +class MicrosoftAzureChaos(object): + """Azure Chaos Resource Provider REST API. + + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: microsoft_azure_chaos.operations.CapabilitiesOperations + :ivar experiments: ExperimentsOperations operations + :vartype experiments: microsoft_azure_chaos.operations.ExperimentsOperations + :ivar operations: Operations operations + :vartype operations: microsoft_azure_chaos.operations.Operations + :ivar targets: TargetsOperations operations + :vartype targets: microsoft_azure_chaos.operations.TargetsOperations + :ivar target_types: TargetTypesOperations operations + :vartype target_types: microsoft_azure_chaos.operations.TargetTypesOperations + :ivar capability_types: CapabilityTypesOperations operations + :vartype capability_types: microsoft_azure_chaos.operations.CapabilityTypesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: GUID that represents an Azure subscription ID. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftAzureChaosConfiguration(credential, subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.capabilities = CapabilitiesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.experiments = ExperimentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.targets = TargetsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.target_types = TargetTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.capability_types = CapabilityTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MicrosoftAzureChaos + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_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/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py new file mode 100644 index 000000000000..0f67b9cee10c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._microsoft_azure_chaos import MicrosoftAzureChaos +__all__ = ['MicrosoftAzureChaos'] diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py new file mode 100644 index 000000000000..e3cbf18ebd0b --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftAzureChaosConfiguration(Configuration): + """Configuration for MicrosoftAzureChaos. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: GUID that represents an Azure subscription ID. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(MicrosoftAzureChaosConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-09-15-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-chaos/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_microsoft_azure_chaos.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_microsoft_azure_chaos.py new file mode 100644 index 000000000000..e4daf6cdb935 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_microsoft_azure_chaos.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import MicrosoftAzureChaosConfiguration +from .operations import CapabilitiesOperations +from .operations import ExperimentsOperations +from .operations import Operations +from .operations import TargetsOperations +from .operations import TargetTypesOperations +from .operations import CapabilityTypesOperations +from .. import models + + +class MicrosoftAzureChaos(object): + """Azure Chaos Resource Provider REST API. + + :ivar capabilities: CapabilitiesOperations operations + :vartype capabilities: microsoft_azure_chaos.aio.operations.CapabilitiesOperations + :ivar experiments: ExperimentsOperations operations + :vartype experiments: microsoft_azure_chaos.aio.operations.ExperimentsOperations + :ivar operations: Operations operations + :vartype operations: microsoft_azure_chaos.aio.operations.Operations + :ivar targets: TargetsOperations operations + :vartype targets: microsoft_azure_chaos.aio.operations.TargetsOperations + :ivar target_types: TargetTypesOperations operations + :vartype target_types: microsoft_azure_chaos.aio.operations.TargetTypesOperations + :ivar capability_types: CapabilityTypesOperations operations + :vartype capability_types: microsoft_azure_chaos.aio.operations.CapabilityTypesOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: GUID that represents an Azure subscription ID. + :type subscription_id: str + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftAzureChaosConfiguration(credential, subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False + self._deserialize = Deserializer(client_models) + + self.capabilities = CapabilitiesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.experiments = ExperimentsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.targets = TargetsOperations( + self._client, self._config, self._serialize, self._deserialize) + self.target_types = TargetTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + self.capability_types = CapabilityTypesOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MicrosoftAzureChaos": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/__init__.py new file mode 100644 index 000000000000..14351e04a4bc --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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 ._capabilities_operations import CapabilitiesOperations +from ._experiments_operations import ExperimentsOperations +from ._operations import Operations +from ._targets_operations import TargetsOperations +from ._target_types_operations import TargetTypesOperations +from ._capability_types_operations import CapabilityTypesOperations + +__all__ = [ + 'CapabilitiesOperations', + 'ExperimentsOperations', + 'Operations', + 'TargetsOperations', + 'TargetTypesOperations', + 'CapabilityTypesOperations', +] diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py new file mode 100644 index 000000000000..aaed031c9991 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capabilities_operations.py @@ -0,0 +1,364 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CapabilitiesOperations: + """CapabilitiesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.CapabilityListResult"]: + """Get a list of Capability resources that extend a Target resource.. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CapabilityListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.CapabilityListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CapabilityListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities'} # type: ignore + + async def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> "_models.Capability": + """Get a Capability resource that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Capability, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Capability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Capability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Capability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + **kwargs: Any + ) -> None: + """Delete a Capability that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + capability_name: str, + capability: "_models.Capability", + **kwargs: Any + ) -> "_models.Capability": + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :param capability: Capability resource to be created or updated. + :type capability: ~microsoft_azure_chaos.models.Capability + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Capability, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Capability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Capability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(capability, 'Capability') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Capability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_operations.py new file mode 100644 index 000000000000..d94b0445b823 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_capability_types_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. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CapabilityTypesOperations: + """CapabilityTypesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + location_name: str, + target_type_name: str, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.CapabilityTypeListResult"]: + """Get a list of Capability Type resources for given Target Type and location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CapabilityTypeListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.CapabilityTypeListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('CapabilityTypeListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes'} # type: ignore + + async def get( + self, + location_name: str, + target_type_name: str, + capability_type_name: str, + **kwargs: Any + ) -> "_models.CapabilityType": + """Get a Capability Type resource for given Target Type and location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :param capability_type_name: String that represents a Capability Type resource name. + :type capability_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CapabilityType, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.CapabilityType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityTypeName': self._serialize.url("capability_type_name", capability_type_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CapabilityType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py new file mode 100644 index 000000000000..7e4a4959fbe6 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_experiments_operations.py @@ -0,0 +1,894 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ExperimentsOperations: + """ExperimentsOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_all( + self, + running: Optional[bool] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ExperimentListResult"]: + """Get a list of Experiment resources in a subscription. + + :param running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. + :type running: bool + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.ExperimentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if running is not None: + query_parameters['running'] = self._serialize.query("running", running, 'bool') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments'} # type: ignore + + def list( + self, + resource_group_name: str, + running: Optional[bool] = None, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ExperimentListResult"]: + """Get a list of Experiment resources in a resource group. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. + :type running: bool + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.ExperimentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if running is not None: + query_parameters['running'] = self._serialize.query("running", running, 'bool') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments'} # type: ignore + + async def delete( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> None: + """Delete a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + async def get( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> "_models.Experiment": + """Get a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Experiment, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Experiment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + experiment_name: str, + experiment: "_models.Experiment", + **kwargs: Any + ) -> "_models.Experiment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(experiment, 'Experiment') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + async def begin_create_or_update( + self, + resource_group_name: str, + experiment_name: str, + experiment: "_models.Experiment", + **kwargs: Any + ) -> AsyncLROPoller["_models.Experiment"]: + """Create or update a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param experiment: Experiment resource to be created or updated. + :type experiment: ~microsoft_azure_chaos.models.Experiment + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Experiment or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_azure_chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + experiment=experiment, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + async def _cancel_initial( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> "_models.ExperimentCancelOperationResult": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentCancelOperationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self._cancel_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentCancelOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel'} # type: ignore + + async def begin_cancel( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> AsyncLROPoller["_models.ExperimentCancelOperationResult"]: + """Cancel a running Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ExperimentCancelOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_azure_chaos.models.ExperimentCancelOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentCancelOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._cancel_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ExperimentCancelOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel'} # type: ignore + + async def start( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> "_models.ExperimentStartOperationResult": + """Start a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentStartOperationResult, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentStartOperationResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStartOperationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.start.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentStartOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start'} # type: ignore + + def list_all_statuses( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExperimentStatusListResult"]: + """Get a list of statuses of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentStatusListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.ExperimentStatusListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStatusListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all_statuses.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentStatusListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all_statuses.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses'} # type: ignore + + async def get_status( + self, + resource_group_name: str, + experiment_name: str, + status_id: str, + **kwargs: Any + ) -> "_models.ExperimentStatus": + """Get a status of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param status_id: GUID that represents a Experiment status. + :type status_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentStatus, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_status.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'statusId': self._serialize.url("status_id", status_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses/{statusId}'} # type: ignore + + def list_execution_details( + self, + resource_group_name: str, + experiment_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ExperimentExecutionDetailsListResult"]: + """Get a list of execution details of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentExecutionDetailsListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.ExperimentExecutionDetailsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentExecutionDetailsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_execution_details.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentExecutionDetailsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_execution_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails'} # type: ignore + + async def get_execution_details( + self, + resource_group_name: str, + experiment_name: str, + execution_details_id: str, + **kwargs: Any + ) -> "_models.ExperimentExecutionDetails": + """Get an execution detail of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param execution_details_id: GUID that represents a Experiment execution detail. + :type execution_details_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentExecutionDetails, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentExecutionDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentExecutionDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_execution_details.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'executionDetailsId': self._serialize.url("execution_details_id", execution_details_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentExecutionDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_execution_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py new file mode 100644 index 000000000000..c4c55dd7616c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Get a list all available Operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/providers/Microsoft.Chaos/operations'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py new file mode 100644 index 000000000000..b86d29325a85 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_target_types_operations.py @@ -0,0 +1,177 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TargetTypesOperations: + """TargetTypesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + location_name: str, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TargetTypeListResult"]: + """Get a list of Target Type resources for given location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TargetTypeListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.TargetTypeListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TargetTypeListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes'} # type: ignore + + async def get( + self, + location_name: str, + target_type_name: str, + **kwargs: Any + ) -> "_models.TargetType": + """Get a Target Type resources for given location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TargetType, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.TargetType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TargetType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py new file mode 100644 index 000000000000..ffa3967ab8a3 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_targets_operations.py @@ -0,0 +1,348 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TargetsOperations: + """TargetsOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + continuation_token_parameter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.TargetListResult"]: + """Get a list of Target resources that extend a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TargetListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_azure_chaos.models.TargetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('TargetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets'} # type: ignore + + async def get( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> "_models.Target": + """Get a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Target, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Target + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Target"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Target', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + **kwargs: Any + ) -> None: + """Delete a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore + + async def create_or_update( + self, + resource_group_name: str, + parent_provider_namespace: str, + parent_resource_type: str, + parent_resource_name: str, + target_name: str, + target: "_models.Target", + **kwargs: Any + ) -> "_models.Target": + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param target: Target resource to be created or updated. + :type target: ~microsoft_azure_chaos.models.Target + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Target, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Target + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Target"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(target, 'Target') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Target', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py new file mode 100644 index 000000000000..e0e888f73712 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py @@ -0,0 +1,149 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import Action + from ._models_py3 import ActionStatus + from ._models_py3 import Branch + from ._models_py3 import BranchStatus + from ._models_py3 import Capability + from ._models_py3 import CapabilityListResult + from ._models_py3 import CapabilityType + from ._models_py3 import CapabilityTypeListResult + from ._models_py3 import ContinuousAction + from ._models_py3 import DelayAction + from ._models_py3 import DiscreteAction + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import Experiment + from ._models_py3 import ExperimentCancelOperationResult + from ._models_py3 import ExperimentExecutionActionTargetDetailsError + from ._models_py3 import ExperimentExecutionActionTargetDetailsProperties + from ._models_py3 import ExperimentExecutionDetails + from ._models_py3 import ExperimentExecutionDetailsListResult + from ._models_py3 import ExperimentExecutionDetailsPropertiesRunInformation + from ._models_py3 import ExperimentListResult + from ._models_py3 import ExperimentStartOperationResult + from ._models_py3 import ExperimentStatus + from ._models_py3 import ExperimentStatusListResult + from ._models_py3 import KeyValuePair + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import Resource + from ._models_py3 import ResourceIdentity + from ._models_py3 import Selector + from ._models_py3 import Step + from ._models_py3 import StepStatus + from ._models_py3 import SystemData + from ._models_py3 import Target + from ._models_py3 import TargetListResult + from ._models_py3 import TargetReference + from ._models_py3 import TargetType + from ._models_py3 import TargetTypeListResult + from ._models_py3 import TrackedResource +except (SyntaxError, ImportError): + from ._models import Action # type: ignore + from ._models import ActionStatus # type: ignore + from ._models import Branch # type: ignore + from ._models import BranchStatus # type: ignore + from ._models import Capability # type: ignore + from ._models import CapabilityListResult # type: ignore + from ._models import CapabilityType # type: ignore + from ._models import CapabilityTypeListResult # type: ignore + from ._models import ContinuousAction # type: ignore + from ._models import DelayAction # type: ignore + from ._models import DiscreteAction # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Experiment # type: ignore + from ._models import ExperimentCancelOperationResult # type: ignore + from ._models import ExperimentExecutionActionTargetDetailsError # type: ignore + from ._models import ExperimentExecutionActionTargetDetailsProperties # type: ignore + from ._models import ExperimentExecutionDetails # type: ignore + from ._models import ExperimentExecutionDetailsListResult # type: ignore + from ._models import ExperimentExecutionDetailsPropertiesRunInformation # type: ignore + from ._models import ExperimentListResult # type: ignore + from ._models import ExperimentStartOperationResult # type: ignore + from ._models import ExperimentStatus # type: ignore + from ._models import ExperimentStatusListResult # type: ignore + from ._models import KeyValuePair # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import Resource # type: ignore + from ._models import ResourceIdentity # type: ignore + from ._models import Selector # type: ignore + from ._models import Step # type: ignore + from ._models import StepStatus # type: ignore + from ._models import SystemData # type: ignore + from ._models import Target # type: ignore + from ._models import TargetListResult # type: ignore + from ._models import TargetReference # type: ignore + from ._models import TargetType # type: ignore + from ._models import TargetTypeListResult # type: ignore + from ._models import TrackedResource # type: ignore + +from ._microsoft_azure_chaos_enums import ( + ActionType, + CreatedByType, + Origin, + ResourceIdentityType, + SelectorType, +) + +__all__ = [ + 'Action', + 'ActionStatus', + 'Branch', + 'BranchStatus', + 'Capability', + 'CapabilityListResult', + 'CapabilityType', + 'CapabilityTypeListResult', + 'ContinuousAction', + 'DelayAction', + 'DiscreteAction', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'Experiment', + 'ExperimentCancelOperationResult', + 'ExperimentExecutionActionTargetDetailsError', + 'ExperimentExecutionActionTargetDetailsProperties', + 'ExperimentExecutionDetails', + 'ExperimentExecutionDetailsListResult', + 'ExperimentExecutionDetailsPropertiesRunInformation', + 'ExperimentListResult', + 'ExperimentStartOperationResult', + 'ExperimentStatus', + 'ExperimentStatusListResult', + 'KeyValuePair', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'Resource', + 'ResourceIdentity', + 'Selector', + 'Step', + 'StepStatus', + 'SystemData', + 'Target', + 'TargetListResult', + 'TargetReference', + 'TargetType', + 'TargetTypeListResult', + 'TrackedResource', + 'ActionType', + 'CreatedByType', + 'Origin', + 'ResourceIdentityType', + 'SelectorType', +] diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_microsoft_azure_chaos_enums.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_microsoft_azure_chaos_enums.py new file mode 100644 index 000000000000..49b325c52be4 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_microsoft_azure_chaos_enums.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """String of the resource identity type. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + +class SelectorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Enum of the selector type. + """ + + PERCENT = "Percent" + RANDOM = "Random" + TAG = "Tag" + LIST = "List" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py new file mode 100644 index 000000000000..ca1e4fc6d913 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models.py @@ -0,0 +1,1635 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class Action(msrest.serialization.Model): + """Model that represents the base action model. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ContinuousAction, DelayAction, DiscreteAction. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'continuous': 'ContinuousAction', 'delay': 'DelayAction', 'discrete': 'DiscreteAction'} + } + + def __init__( + self, + **kwargs + ): + super(Action, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.name = kwargs['name'] + + +class ActionStatus(msrest.serialization.Model): + """Model that represents the an action and its status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the action status. + :vartype name: str + :ivar id: The id of the action status. + :vartype id: str + :ivar status: The status of the action. + :vartype status: str + :ivar targets: The array of targets. + :vartype targets: + list[~microsoft_azure_chaos.models.ExperimentExecutionActionTargetDetailsProperties] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'targets': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[ExperimentExecutionActionTargetDetailsProperties]'}, + } + + def __init__( + self, + **kwargs + ): + super(ActionStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.targets = None + + +class Branch(msrest.serialization.Model): + """Model that represents a branch in the step. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. String of the branch name. + :type name: str + :param actions: Required. List of actions. + :type actions: list[~microsoft_azure_chaos.models.Action] + """ + + _validation = { + 'name': {'required': True, 'min_length': 1}, + 'actions': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[Action]'}, + } + + def __init__( + self, + **kwargs + ): + super(Branch, self).__init__(**kwargs) + self.name = kwargs['name'] + self.actions = kwargs['actions'] + + +class BranchStatus(msrest.serialization.Model): + """Model that represents the a list of actions and action statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the branch status. + :vartype name: str + :ivar id: The id of the branch status. + :vartype id: str + :ivar status: The status of the branch. + :vartype status: str + :ivar actions: The array of actions. + :vartype actions: list[~microsoft_azure_chaos.models.ActionStatus] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'actions': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[ActionStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(BranchStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.actions = None + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Capability(Resource): + """Model that represents a Capability resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The standard system metadata of a resource type. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :ivar publisher: String of the Publisher that this Capability extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability extends. + :vartype target_type: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher': {'readonly': True}, + 'target_type': {'readonly': True}, + 'description': {'readonly': True}, + 'parameters_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'urn': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'parameters_schema': {'key': 'properties.parametersSchema', 'type': 'str'}, + 'urn': {'key': 'properties.urn', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Capability, self).__init__(**kwargs) + self.system_data = None + self.publisher = None + self.target_type = None + self.description = None + self.parameters_schema = None + self.urn = None + + +class CapabilityListResult(msrest.serialization.Model): + """Model that represents a list of Capability resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Capability resources. + :vartype value: list[~microsoft_azure_chaos.models.Capability] + :ivar next_link: URL to retrieve the next page of Capability resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Capability]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CapabilityListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CapabilityType(Resource): + """Model that represents a Capability Type resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata properties of the capability type resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the Capability Type resource. + :type location: str + :ivar publisher: String of the Publisher that this Capability Type extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability Type extends. + :vartype target_type: str + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability Type parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher': {'readonly': True}, + 'target_type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'parameters_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'urn': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'parameters_schema': {'key': 'properties.parametersSchema', 'type': 'str'}, + 'urn': {'key': 'properties.urn', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CapabilityType, self).__init__(**kwargs) + self.system_data = None + self.location = kwargs.get('location', None) + self.publisher = None + self.target_type = None + self.display_name = None + self.description = None + self.parameters_schema = None + self.urn = None + + +class CapabilityTypeListResult(msrest.serialization.Model): + """Model that represents a list of Capability Type resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Capability Type resources. + :vartype value: list[~microsoft_azure_chaos.models.CapabilityType] + :ivar next_link: URL to retrieve the next page of Capability Type resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CapabilityType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CapabilityTypeListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContinuousAction(Action): + """Model that represents a continuous action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param duration: Required. ISO8601 formatted string that represents a duration. + :type duration: str + :param parameters: Required. List of key value pairs. + :type parameters: list[~microsoft_azure_chaos.models.KeyValuePair] + :param selector_id: Required. String that represents a selector. + :type selector_id: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'duration': {'required': True, 'pattern': r'^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$'}, + 'parameters': {'required': True}, + 'selector_id': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '[KeyValuePair]'}, + 'selector_id': {'key': 'selectorId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ContinuousAction, self).__init__(**kwargs) + self.type = 'continuous' # type: str + self.duration = kwargs['duration'] + self.parameters = kwargs['parameters'] + self.selector_id = kwargs['selector_id'] + + +class DelayAction(Action): + """Model that represents a delay action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param duration: Required. ISO8601 formatted string that represents a duration. + :type duration: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'duration': {'required': True, 'pattern': r'^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DelayAction, self).__init__(**kwargs) + self.type = 'delay' # type: str + self.duration = kwargs['duration'] + + +class DiscreteAction(Action): + """Model that represents a discrete action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param parameters: Required. List of key value pairs. + :type parameters: list[~microsoft_azure_chaos.models.KeyValuePair] + :param selector_id: Required. String that represents a selector. + :type selector_id: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'parameters': {'required': True}, + 'selector_id': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '[KeyValuePair]'}, + 'selector_id': {'key': 'selectorId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(DiscreteAction, self).__init__(**kwargs) + self.type = 'discrete' # type: str + self.parameters = kwargs['parameters'] + self.selector_id = kwargs['selector_id'] + + +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 ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~microsoft_azure_chaos.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_azure_chaos.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~microsoft_azure_chaos.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.location = kwargs['location'] + + +class Experiment(TrackedResource): + """Model that represents a Experiment resource. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: The system metadata of the experiment resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param identity: The identity of the experiment resource. + :type identity: ~microsoft_azure_chaos.models.ResourceIdentity + :param steps: Required. List of steps. + :type steps: list[~microsoft_azure_chaos.models.Step] + :param selectors: Required. List of selectors. + :type selectors: list[~microsoft_azure_chaos.models.Selector] + :param start_on_creation: A boolean value that indicates if experiment should be started on + creation or not. + :type start_on_creation: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'steps': {'required': True, 'min_items': 1}, + 'selectors': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, + 'steps': {'key': 'properties.steps', 'type': '[Step]'}, + 'selectors': {'key': 'properties.selectors', 'type': '[Selector]'}, + 'start_on_creation': {'key': 'properties.startOnCreation', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(Experiment, self).__init__(**kwargs) + self.system_data = None + self.identity = kwargs.get('identity', None) + self.steps = kwargs['steps'] + self.selectors = kwargs['selectors'] + self.start_on_creation = kwargs.get('start_on_creation', None) + + +class ExperimentCancelOperationResult(msrest.serialization.Model): + """Model that represents the result of a cancel Experiment operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: String of the Experiment name. + :vartype name: str + :ivar status_url: URL to retrieve the Experiment status. + :vartype status_url: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status_url': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status_url': {'key': 'statusUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentCancelOperationResult, self).__init__(**kwargs) + self.name = None + self.status_url = None + + +class ExperimentExecutionActionTargetDetailsError(msrest.serialization.Model): + """Model that represents the Experiment action target details error model. + + 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 + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionActionTargetDetailsError, self).__init__(**kwargs) + self.code = None + self.message = None + + +class ExperimentExecutionActionTargetDetailsProperties(msrest.serialization.Model): + """Model that represents the Experiment action target details properties model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the execution. + :vartype status: str + :ivar target: The target for the action. + :vartype target: str + :ivar failed_date_utc: String that represents the failed date time. + :vartype failed_date_utc: ~datetime.datetime + :ivar completed_date_utc: String that represents the completed date time. + :vartype completed_date_utc: ~datetime.datetime + :ivar error: The error of the action. + :vartype error: ~microsoft_azure_chaos.models.ExperimentExecutionActionTargetDetailsError + """ + + _validation = { + 'status': {'readonly': True}, + 'target': {'readonly': True}, + 'failed_date_utc': {'readonly': True}, + 'completed_date_utc': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'failed_date_utc': {'key': 'failedDateUtc', 'type': 'iso-8601'}, + 'completed_date_utc': {'key': 'completedDateUtc', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'ExperimentExecutionActionTargetDetailsError'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionActionTargetDetailsProperties, self).__init__(**kwargs) + self.status = None + self.target = None + self.failed_date_utc = None + self.completed_date_utc = None + self.error = None + + +class ExperimentExecutionDetails(msrest.serialization.Model): + """Model that represents the execution details of a Experiment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: String of the resource type. + :vartype type: str + :ivar id: String of the fully qualified resource ID. + :vartype id: str + :ivar name: String of the resource name. + :vartype name: str + :ivar experiment_id: The id of the experiment. + :vartype experiment_id: str + :ivar status: The value of the status of the experiment execution. + :vartype status: str + :ivar failure_reason: The reason why the execution failed. + :vartype failure_reason: str + :ivar created_date_utc: String that represents the created date time. + :vartype created_date_utc: ~datetime.datetime + :ivar last_action_date_utc: String that represents the last action date time. + :vartype last_action_date_utc: ~datetime.datetime + :ivar start_date_utc: String that represents the start date time. + :vartype start_date_utc: ~datetime.datetime + :ivar stop_date_utc: String that represents the stop date time. + :vartype stop_date_utc: ~datetime.datetime + :ivar run_information: The information of the experiment run. + :vartype run_information: + ~microsoft_azure_chaos.models.ExperimentExecutionDetailsPropertiesRunInformation + """ + + _validation = { + 'type': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'experiment_id': {'readonly': True}, + 'status': {'readonly': True}, + 'failure_reason': {'readonly': True}, + 'created_date_utc': {'readonly': True}, + 'last_action_date_utc': {'readonly': True}, + 'start_date_utc': {'readonly': True}, + 'stop_date_utc': {'readonly': True}, + 'run_information': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'experiment_id': {'key': 'properties.experimentId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'failure_reason': {'key': 'properties.failureReason', 'type': 'str'}, + 'created_date_utc': {'key': 'properties.createdDateUtc', 'type': 'iso-8601'}, + 'last_action_date_utc': {'key': 'properties.lastActionDateUtc', 'type': 'iso-8601'}, + 'start_date_utc': {'key': 'properties.startDateUtc', 'type': 'iso-8601'}, + 'stop_date_utc': {'key': 'properties.stopDateUtc', 'type': 'iso-8601'}, + 'run_information': {'key': 'properties.runInformation', 'type': 'ExperimentExecutionDetailsPropertiesRunInformation'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetails, self).__init__(**kwargs) + self.type = None + self.id = None + self.name = None + self.experiment_id = None + self.status = None + self.failure_reason = None + self.created_date_utc = None + self.last_action_date_utc = None + self.start_date_utc = None + self.stop_date_utc = None + self.run_information = None + + +class ExperimentExecutionDetailsListResult(msrest.serialization.Model): + """Model that represents a list of Experiment execution details and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment execution details. + :vartype value: list[~microsoft_azure_chaos.models.ExperimentExecutionDetails] + :ivar next_link: URL to retrieve the next page of Experiment execution details. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExperimentExecutionDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetailsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExperimentExecutionDetailsPropertiesRunInformation(msrest.serialization.Model): + """The information of the experiment run. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar steps: The steps of the experiment run. + :vartype steps: list[~microsoft_azure_chaos.models.StepStatus] + """ + + _validation = { + 'steps': {'readonly': True}, + } + + _attribute_map = { + 'steps': {'key': 'steps', 'type': '[StepStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetailsPropertiesRunInformation, self).__init__(**kwargs) + self.steps = None + + +class ExperimentListResult(msrest.serialization.Model): + """Model that represents a list of Experiment resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment resources. + :vartype value: list[~microsoft_azure_chaos.models.Experiment] + :ivar next_link: URL to retrieve the next page of Experiment resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Experiment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExperimentStartOperationResult(msrest.serialization.Model): + """Model that represents the result of a start Experiment operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: String of the Experiment name. + :vartype name: str + :ivar status_url: URL to retrieve the Experiment status. + :vartype status_url: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status_url': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status_url': {'key': 'statusUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStartOperationResult, self).__init__(**kwargs) + self.name = None + self.status_url = None + + +class ExperimentStatus(msrest.serialization.Model): + """Model that represents the status of a Experiment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: String of the resource type. + :vartype type: str + :ivar id: String of the fully qualified resource ID. + :vartype id: str + :ivar name: String of the resource name. + :vartype name: str + :ivar status: String that represents the status of a Experiment. + :vartype status: str + :ivar created_date_utc: String that represents the created date time of a Experiment. + :vartype created_date_utc: ~datetime.datetime + :ivar end_date_utc: String that represents the end date time of a Experiment. + :vartype end_date_utc: ~datetime.datetime + """ + + _validation = { + 'type': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'status': {'readonly': True}, + 'created_date_utc': {'readonly': True}, + 'end_date_utc': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'created_date_utc': {'key': 'properties.createdDateUtc', 'type': 'iso-8601'}, + 'end_date_utc': {'key': 'properties.endDateUtc', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStatus, self).__init__(**kwargs) + self.type = None + self.id = None + self.name = None + self.status = None + self.created_date_utc = None + self.end_date_utc = None + + +class ExperimentStatusListResult(msrest.serialization.Model): + """Model that represents a list of Experiment statuses and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment statuses. + :vartype value: list[~microsoft_azure_chaos.models.ExperimentStatus] + :ivar next_link: URL to retrieve the next page of Experiment statuses. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExperimentStatus]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStatusListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class KeyValuePair(msrest.serialization.Model): + """A map to describe the settings of an action. + + All required parameters must be populated in order to send to Azure. + + :param key: Required. The name of the setting for the action. + :type key: str + :param value: Required. The value of the setting for the action. + :type value: str + """ + + _validation = { + 'key': {'required': True, 'min_length': 1}, + 'value': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(KeyValuePair, self).__init__(**kwargs) + self.key = kwargs['key'] + self.value = kwargs['value'] + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~microsoft_azure_chaos.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~microsoft_azure_chaos.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~microsoft_azure_chaos.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = kwargs.get('display', None) + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~microsoft_azure_chaos.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ResourceIdentity(msrest.serialization.Model): + """The managed identity of a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. String of the resource identity type. Possible values include: "None", + "SystemAssigned". + :type type: str or ~microsoft_azure_chaos.models.ResourceIdentityType + :ivar principal_id: GUID that represents the principal ID of this resource identity. + :vartype principal_id: str + :ivar tenant_id: GUID that represents the tenant ID of this resource identity. + :vartype tenant_id: str + """ + + _validation = { + 'type': {'required': True}, + 'principal_id': {'readonly': True, 'pattern': r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'}, + 'tenant_id': {'readonly': True, 'pattern': r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceIdentity, self).__init__(**kwargs) + self.type = kwargs['type'] + self.principal_id = None + self.tenant_id = None + + +class Selector(msrest.serialization.Model): + """Model that represents a selector in the Experiment resource. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum of the selector type. Possible values include: "Percent", "Random", + "Tag", "List". + :type type: str or ~microsoft_azure_chaos.models.SelectorType + :param id: Required. String of the selector ID. + :type id: str + :param targets: Required. List of Target references. + :type targets: list[~microsoft_azure_chaos.models.TargetReference] + """ + + _validation = { + 'type': {'required': True}, + 'id': {'required': True, 'min_length': 1}, + 'targets': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[TargetReference]'}, + } + + def __init__( + self, + **kwargs + ): + super(Selector, self).__init__(**kwargs) + self.type = kwargs['type'] + self.id = kwargs['id'] + self.targets = kwargs['targets'] + + +class Step(msrest.serialization.Model): + """Model that represents a step in the Experiment resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. String of the step name. + :type name: str + :param branches: Required. List of branches. + :type branches: list[~microsoft_azure_chaos.models.Branch] + """ + + _validation = { + 'name': {'required': True, 'min_length': 1}, + 'branches': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'branches': {'key': 'branches', 'type': '[Branch]'}, + } + + def __init__( + self, + **kwargs + ): + super(Step, self).__init__(**kwargs) + self.name = kwargs['name'] + self.branches = kwargs['branches'] + + +class StepStatus(msrest.serialization.Model): + """Model that represents the a list of branches and branch statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the step. + :vartype name: str + :ivar id: The id of the step. + :vartype id: str + :ivar status: The value of the status of the step. + :vartype status: str + :ivar branches: The array of branches. + :vartype branches: list[~microsoft_azure_chaos.models.BranchStatus] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'branches': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'branches': {'key': 'branches', 'type': '[BranchStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(StepStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.branches = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_azure_chaos.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_azure_chaos.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class Target(Resource): + """Model that represents a Target resource. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata of the target resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the target resource. + :type location: str + :param properties: Required. The properties of the target resource. + :type properties: dict[str, any] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{object}'}, + } + + def __init__( + self, + **kwargs + ): + super(Target, self).__init__(**kwargs) + self.system_data = None + self.location = kwargs.get('location', None) + self.properties = kwargs['properties'] + + +class TargetListResult(msrest.serialization.Model): + """Model that represents a list of Target resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Target resources. + :vartype value: list[~microsoft_azure_chaos.models.Target] + :ivar next_link: URL to retrieve the next page of Target resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Target]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class TargetReference(msrest.serialization.Model): + """Model that represents a reference to a Target in the selector. + + 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 type: Enum of the Target reference type. Has constant value: "ResourceId". + :vartype type: str + :param id: Required. String of the resource ID of a Target resource. + :type id: str + """ + + _validation = { + 'type': {'required': True, 'constant': True}, + 'id': {'required': True, 'pattern': r'^\/[Ss][Uu][Bb][Ss][Cc][Rr][Ii][Pp][Tt][Ii][Oo][Nn][Ss]\/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\/[Rr][Ee][Ss][Oo][Uu][Rr][Cc][Ee][Gg][Rr][Oo][Uu][Pp][Ss]\/[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]\/[Pp][Rr][Oo][Vv][Ii][Dd][Ee][Rr][Ss]\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+\/[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+\/[Pp][Rr][Oo][Vv][Ii][Dd][Ee][Rr][Ss]\/[Mm][Ii][Cc][Rr][Oo][Ss][Oo][Ff][Tt]\.[Cc][Hh][Aa][Oo][Ss]\/[Tt][Aa][Rr][Gg][Ee][Tt][Ss]\/[a-zA-Z0-9_\-\.]+$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + type = "ResourceId" + + def __init__( + self, + **kwargs + ): + super(TargetReference, self).__init__(**kwargs) + self.id = kwargs['id'] + + +class TargetType(Resource): + """Model that represents a Target Type resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata properties of the target type resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the Target Type resource. + :type location: str + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar properties_schema: URL to retrieve JSON schema of the Target Type properties. + :vartype properties_schema: str + :ivar resource_types: List of resource types this Target Type can extend. + :vartype resource_types: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'properties_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'resource_types': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'properties_schema': {'key': 'properties.propertiesSchema', 'type': 'str'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetType, self).__init__(**kwargs) + self.system_data = None + self.location = kwargs.get('location', None) + self.display_name = None + self.description = None + self.properties_schema = None + self.resource_types = None + + +class TargetTypeListResult(msrest.serialization.Model): + """Model that represents a list of Target Type resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Target Type resources. + :vartype value: list[~microsoft_azure_chaos.models.TargetType] + :ivar next_link: URL to retrieve the next page of Target Type resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TargetType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetTypeListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py new file mode 100644 index 000000000000..af61a388bb18 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_models_py3.py @@ -0,0 +1,1699 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._microsoft_azure_chaos_enums import * + + +class Action(msrest.serialization.Model): + """Model that represents the base action model. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ContinuousAction, DelayAction, DiscreteAction. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'continuous': 'ContinuousAction', 'delay': 'DelayAction', 'discrete': 'DiscreteAction'} + } + + def __init__( + self, + *, + name: str, + **kwargs + ): + super(Action, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.name = name + + +class ActionStatus(msrest.serialization.Model): + """Model that represents the an action and its status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the action status. + :vartype name: str + :ivar id: The id of the action status. + :vartype id: str + :ivar status: The status of the action. + :vartype status: str + :ivar targets: The array of targets. + :vartype targets: + list[~microsoft_azure_chaos.models.ExperimentExecutionActionTargetDetailsProperties] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'targets': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[ExperimentExecutionActionTargetDetailsProperties]'}, + } + + def __init__( + self, + **kwargs + ): + super(ActionStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.targets = None + + +class Branch(msrest.serialization.Model): + """Model that represents a branch in the step. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. String of the branch name. + :type name: str + :param actions: Required. List of actions. + :type actions: list[~microsoft_azure_chaos.models.Action] + """ + + _validation = { + 'name': {'required': True, 'min_length': 1}, + 'actions': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[Action]'}, + } + + def __init__( + self, + *, + name: str, + actions: List["Action"], + **kwargs + ): + super(Branch, self).__init__(**kwargs) + self.name = name + self.actions = actions + + +class BranchStatus(msrest.serialization.Model): + """Model that represents the a list of actions and action statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the branch status. + :vartype name: str + :ivar id: The id of the branch status. + :vartype id: str + :ivar status: The status of the branch. + :vartype status: str + :ivar actions: The array of actions. + :vartype actions: list[~microsoft_azure_chaos.models.ActionStatus] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'actions': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'actions': {'key': 'actions', 'type': '[ActionStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(BranchStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.actions = None + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Capability(Resource): + """Model that represents a Capability resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The standard system metadata of a resource type. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :ivar publisher: String of the Publisher that this Capability extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability extends. + :vartype target_type: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher': {'readonly': True}, + 'target_type': {'readonly': True}, + 'description': {'readonly': True}, + 'parameters_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'urn': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'parameters_schema': {'key': 'properties.parametersSchema', 'type': 'str'}, + 'urn': {'key': 'properties.urn', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Capability, self).__init__(**kwargs) + self.system_data = None + self.publisher = None + self.target_type = None + self.description = None + self.parameters_schema = None + self.urn = None + + +class CapabilityListResult(msrest.serialization.Model): + """Model that represents a list of Capability resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Capability resources. + :vartype value: list[~microsoft_azure_chaos.models.Capability] + :ivar next_link: URL to retrieve the next page of Capability resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Capability]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CapabilityListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class CapabilityType(Resource): + """Model that represents a Capability Type resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata properties of the capability type resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the Capability Type resource. + :type location: str + :ivar publisher: String of the Publisher that this Capability Type extends. + :vartype publisher: str + :ivar target_type: String of the Target Type that this Capability Type extends. + :vartype target_type: str + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar parameters_schema: URL to retrieve JSON schema of the Capability Type parameters. + :vartype parameters_schema: str + :ivar urn: String of the URN for this Capability Type. + :vartype urn: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'publisher': {'readonly': True}, + 'target_type': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'parameters_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'urn': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'target_type': {'key': 'properties.targetType', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'parameters_schema': {'key': 'properties.parametersSchema', 'type': 'str'}, + 'urn': {'key': 'properties.urn', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): + super(CapabilityType, self).__init__(**kwargs) + self.system_data = None + self.location = location + self.publisher = None + self.target_type = None + self.display_name = None + self.description = None + self.parameters_schema = None + self.urn = None + + +class CapabilityTypeListResult(msrest.serialization.Model): + """Model that represents a list of Capability Type resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Capability Type resources. + :vartype value: list[~microsoft_azure_chaos.models.CapabilityType] + :ivar next_link: URL to retrieve the next page of Capability Type resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CapabilityType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CapabilityTypeListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ContinuousAction(Action): + """Model that represents a continuous action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param duration: Required. ISO8601 formatted string that represents a duration. + :type duration: str + :param parameters: Required. List of key value pairs. + :type parameters: list[~microsoft_azure_chaos.models.KeyValuePair] + :param selector_id: Required. String that represents a selector. + :type selector_id: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'duration': {'required': True, 'pattern': r'^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$'}, + 'parameters': {'required': True}, + 'selector_id': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '[KeyValuePair]'}, + 'selector_id': {'key': 'selectorId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + duration: str, + parameters: List["KeyValuePair"], + selector_id: str, + **kwargs + ): + super(ContinuousAction, self).__init__(name=name, **kwargs) + self.type = 'continuous' # type: str + self.duration = duration + self.parameters = parameters + self.selector_id = selector_id + + +class DelayAction(Action): + """Model that represents a delay action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param duration: Required. ISO8601 formatted string that represents a duration. + :type duration: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'duration': {'required': True, 'pattern': r'^P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+(\.\d+)?S)?)?$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'duration': {'key': 'duration', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + duration: str, + **kwargs + ): + super(DelayAction, self).__init__(name=name, **kwargs) + self.type = 'delay' # type: str + self.duration = duration + + +class DiscreteAction(Action): + """Model that represents a discrete action. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum that discriminates between action models.Constant filled by server. + :type type: str + :param name: Required. String that represents a Capability URN. + :type name: str + :param parameters: Required. List of key value pairs. + :type parameters: list[~microsoft_azure_chaos.models.KeyValuePair] + :param selector_id: Required. String that represents a selector. + :type selector_id: str + """ + + _validation = { + 'type': {'required': True}, + 'name': {'required': True, 'max_length': 2048, 'min_length': 0}, + 'parameters': {'required': True}, + 'selector_id': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': '[KeyValuePair]'}, + 'selector_id': {'key': 'selectorId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + parameters: List["KeyValuePair"], + selector_id: str, + **kwargs + ): + super(DiscreteAction, self).__init__(name=name, **kwargs) + self.type = 'discrete' # type: str + self.parameters = parameters + self.selector_id = selector_id + + +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 ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~microsoft_azure_chaos.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~microsoft_azure_chaos.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~microsoft_azure_chaos.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class Experiment(TrackedResource): + """Model that represents a Experiment resource. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: The system metadata of the experiment resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param identity: The identity of the experiment resource. + :type identity: ~microsoft_azure_chaos.models.ResourceIdentity + :param steps: Required. List of steps. + :type steps: list[~microsoft_azure_chaos.models.Step] + :param selectors: Required. List of selectors. + :type selectors: list[~microsoft_azure_chaos.models.Selector] + :param start_on_creation: A boolean value that indicates if experiment should be started on + creation or not. + :type start_on_creation: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'steps': {'required': True, 'min_items': 1}, + 'selectors': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'identity': {'key': 'identity', 'type': 'ResourceIdentity'}, + 'steps': {'key': 'properties.steps', 'type': '[Step]'}, + 'selectors': {'key': 'properties.selectors', 'type': '[Selector]'}, + 'start_on_creation': {'key': 'properties.startOnCreation', 'type': 'bool'}, + } + + def __init__( + self, + *, + location: str, + steps: List["Step"], + selectors: List["Selector"], + tags: Optional[Dict[str, str]] = None, + identity: Optional["ResourceIdentity"] = None, + start_on_creation: Optional[bool] = None, + **kwargs + ): + super(Experiment, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.identity = identity + self.steps = steps + self.selectors = selectors + self.start_on_creation = start_on_creation + + +class ExperimentCancelOperationResult(msrest.serialization.Model): + """Model that represents the result of a cancel Experiment operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: String of the Experiment name. + :vartype name: str + :ivar status_url: URL to retrieve the Experiment status. + :vartype status_url: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status_url': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status_url': {'key': 'statusUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentCancelOperationResult, self).__init__(**kwargs) + self.name = None + self.status_url = None + + +class ExperimentExecutionActionTargetDetailsError(msrest.serialization.Model): + """Model that represents the Experiment action target details error model. + + 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 + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionActionTargetDetailsError, self).__init__(**kwargs) + self.code = None + self.message = None + + +class ExperimentExecutionActionTargetDetailsProperties(msrest.serialization.Model): + """Model that represents the Experiment action target details properties model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the execution. + :vartype status: str + :ivar target: The target for the action. + :vartype target: str + :ivar failed_date_utc: String that represents the failed date time. + :vartype failed_date_utc: ~datetime.datetime + :ivar completed_date_utc: String that represents the completed date time. + :vartype completed_date_utc: ~datetime.datetime + :ivar error: The error of the action. + :vartype error: ~microsoft_azure_chaos.models.ExperimentExecutionActionTargetDetailsError + """ + + _validation = { + 'status': {'readonly': True}, + 'target': {'readonly': True}, + 'failed_date_utc': {'readonly': True}, + 'completed_date_utc': {'readonly': True}, + 'error': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'failed_date_utc': {'key': 'failedDateUtc', 'type': 'iso-8601'}, + 'completed_date_utc': {'key': 'completedDateUtc', 'type': 'iso-8601'}, + 'error': {'key': 'error', 'type': 'ExperimentExecutionActionTargetDetailsError'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionActionTargetDetailsProperties, self).__init__(**kwargs) + self.status = None + self.target = None + self.failed_date_utc = None + self.completed_date_utc = None + self.error = None + + +class ExperimentExecutionDetails(msrest.serialization.Model): + """Model that represents the execution details of a Experiment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: String of the resource type. + :vartype type: str + :ivar id: String of the fully qualified resource ID. + :vartype id: str + :ivar name: String of the resource name. + :vartype name: str + :ivar experiment_id: The id of the experiment. + :vartype experiment_id: str + :ivar status: The value of the status of the experiment execution. + :vartype status: str + :ivar failure_reason: The reason why the execution failed. + :vartype failure_reason: str + :ivar created_date_utc: String that represents the created date time. + :vartype created_date_utc: ~datetime.datetime + :ivar last_action_date_utc: String that represents the last action date time. + :vartype last_action_date_utc: ~datetime.datetime + :ivar start_date_utc: String that represents the start date time. + :vartype start_date_utc: ~datetime.datetime + :ivar stop_date_utc: String that represents the stop date time. + :vartype stop_date_utc: ~datetime.datetime + :ivar run_information: The information of the experiment run. + :vartype run_information: + ~microsoft_azure_chaos.models.ExperimentExecutionDetailsPropertiesRunInformation + """ + + _validation = { + 'type': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'experiment_id': {'readonly': True}, + 'status': {'readonly': True}, + 'failure_reason': {'readonly': True}, + 'created_date_utc': {'readonly': True}, + 'last_action_date_utc': {'readonly': True}, + 'start_date_utc': {'readonly': True}, + 'stop_date_utc': {'readonly': True}, + 'run_information': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'experiment_id': {'key': 'properties.experimentId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'failure_reason': {'key': 'properties.failureReason', 'type': 'str'}, + 'created_date_utc': {'key': 'properties.createdDateUtc', 'type': 'iso-8601'}, + 'last_action_date_utc': {'key': 'properties.lastActionDateUtc', 'type': 'iso-8601'}, + 'start_date_utc': {'key': 'properties.startDateUtc', 'type': 'iso-8601'}, + 'stop_date_utc': {'key': 'properties.stopDateUtc', 'type': 'iso-8601'}, + 'run_information': {'key': 'properties.runInformation', 'type': 'ExperimentExecutionDetailsPropertiesRunInformation'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetails, self).__init__(**kwargs) + self.type = None + self.id = None + self.name = None + self.experiment_id = None + self.status = None + self.failure_reason = None + self.created_date_utc = None + self.last_action_date_utc = None + self.start_date_utc = None + self.stop_date_utc = None + self.run_information = None + + +class ExperimentExecutionDetailsListResult(msrest.serialization.Model): + """Model that represents a list of Experiment execution details and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment execution details. + :vartype value: list[~microsoft_azure_chaos.models.ExperimentExecutionDetails] + :ivar next_link: URL to retrieve the next page of Experiment execution details. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExperimentExecutionDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetailsListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExperimentExecutionDetailsPropertiesRunInformation(msrest.serialization.Model): + """The information of the experiment run. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar steps: The steps of the experiment run. + :vartype steps: list[~microsoft_azure_chaos.models.StepStatus] + """ + + _validation = { + 'steps': {'readonly': True}, + } + + _attribute_map = { + 'steps': {'key': 'steps', 'type': '[StepStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentExecutionDetailsPropertiesRunInformation, self).__init__(**kwargs) + self.steps = None + + +class ExperimentListResult(msrest.serialization.Model): + """Model that represents a list of Experiment resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment resources. + :vartype value: list[~microsoft_azure_chaos.models.Experiment] + :ivar next_link: URL to retrieve the next page of Experiment resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Experiment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ExperimentStartOperationResult(msrest.serialization.Model): + """Model that represents the result of a start Experiment operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: String of the Experiment name. + :vartype name: str + :ivar status_url: URL to retrieve the Experiment status. + :vartype status_url: str + """ + + _validation = { + 'name': {'readonly': True}, + 'status_url': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'status_url': {'key': 'statusUrl', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStartOperationResult, self).__init__(**kwargs) + self.name = None + self.status_url = None + + +class ExperimentStatus(msrest.serialization.Model): + """Model that represents the status of a Experiment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: String of the resource type. + :vartype type: str + :ivar id: String of the fully qualified resource ID. + :vartype id: str + :ivar name: String of the resource name. + :vartype name: str + :ivar status: String that represents the status of a Experiment. + :vartype status: str + :ivar created_date_utc: String that represents the created date time of a Experiment. + :vartype created_date_utc: ~datetime.datetime + :ivar end_date_utc: String that represents the end date time of a Experiment. + :vartype end_date_utc: ~datetime.datetime + """ + + _validation = { + 'type': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'status': {'readonly': True}, + 'created_date_utc': {'readonly': True}, + 'end_date_utc': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'created_date_utc': {'key': 'properties.createdDateUtc', 'type': 'iso-8601'}, + 'end_date_utc': {'key': 'properties.endDateUtc', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStatus, self).__init__(**kwargs) + self.type = None + self.id = None + self.name = None + self.status = None + self.created_date_utc = None + self.end_date_utc = None + + +class ExperimentStatusListResult(msrest.serialization.Model): + """Model that represents a list of Experiment statuses and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Experiment statuses. + :vartype value: list[~microsoft_azure_chaos.models.ExperimentStatus] + :ivar next_link: URL to retrieve the next page of Experiment statuses. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ExperimentStatus]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExperimentStatusListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class KeyValuePair(msrest.serialization.Model): + """A map to describe the settings of an action. + + All required parameters must be populated in order to send to Azure. + + :param key: Required. The name of the setting for the action. + :type key: str + :param value: Required. The value of the setting for the action. + :type value: str + """ + + _validation = { + 'key': {'required': True, 'min_length': 1}, + 'value': {'required': True, 'min_length': 1}, + } + + _attribute_map = { + 'key': {'key': 'key', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + key: str, + value: str, + **kwargs + ): + super(KeyValuePair, self).__init__(**kwargs) + self.key = key + self.value = value + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~microsoft_azure_chaos.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~microsoft_azure_chaos.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~microsoft_azure_chaos.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~microsoft_azure_chaos.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ResourceIdentity(msrest.serialization.Model): + """The managed identity of a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. String of the resource identity type. Possible values include: "None", + "SystemAssigned". + :type type: str or ~microsoft_azure_chaos.models.ResourceIdentityType + :ivar principal_id: GUID that represents the principal ID of this resource identity. + :vartype principal_id: str + :ivar tenant_id: GUID that represents the tenant ID of this resource identity. + :vartype tenant_id: str + """ + + _validation = { + 'type': {'required': True}, + 'principal_id': {'readonly': True, 'pattern': r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'}, + 'tenant_id': {'readonly': True, 'pattern': r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Union[str, "ResourceIdentityType"], + **kwargs + ): + super(ResourceIdentity, self).__init__(**kwargs) + self.type = type + self.principal_id = None + self.tenant_id = None + + +class Selector(msrest.serialization.Model): + """Model that represents a selector in the Experiment resource. + + All required parameters must be populated in order to send to Azure. + + :param type: Required. Enum of the selector type. Possible values include: "Percent", "Random", + "Tag", "List". + :type type: str or ~microsoft_azure_chaos.models.SelectorType + :param id: Required. String of the selector ID. + :type id: str + :param targets: Required. List of Target references. + :type targets: list[~microsoft_azure_chaos.models.TargetReference] + """ + + _validation = { + 'type': {'required': True}, + 'id': {'required': True, 'min_length': 1}, + 'targets': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[TargetReference]'}, + } + + def __init__( + self, + *, + type: Union[str, "SelectorType"], + id: str, + targets: List["TargetReference"], + **kwargs + ): + super(Selector, self).__init__(**kwargs) + self.type = type + self.id = id + self.targets = targets + + +class Step(msrest.serialization.Model): + """Model that represents a step in the Experiment resource. + + All required parameters must be populated in order to send to Azure. + + :param name: Required. String of the step name. + :type name: str + :param branches: Required. List of branches. + :type branches: list[~microsoft_azure_chaos.models.Branch] + """ + + _validation = { + 'name': {'required': True, 'min_length': 1}, + 'branches': {'required': True, 'min_items': 1}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'branches': {'key': 'branches', 'type': '[Branch]'}, + } + + def __init__( + self, + *, + name: str, + branches: List["Branch"], + **kwargs + ): + super(Step, self).__init__(**kwargs) + self.name = name + self.branches = branches + + +class StepStatus(msrest.serialization.Model): + """Model that represents the a list of branches and branch statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the step. + :vartype name: str + :ivar id: The id of the step. + :vartype id: str + :ivar status: The value of the status of the step. + :vartype status: str + :ivar branches: The array of branches. + :vartype branches: list[~microsoft_azure_chaos.models.BranchStatus] + """ + + _validation = { + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'status': {'readonly': True}, + 'branches': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'branches': {'key': 'branches', 'type': '[BranchStatus]'}, + } + + def __init__( + self, + **kwargs + ): + super(StepStatus, self).__init__(**kwargs) + self.name = None + self.id = None + self.status = None + self.branches = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~microsoft_azure_chaos.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~microsoft_azure_chaos.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Target(Resource): + """Model that represents a Target resource. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata of the target resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the target resource. + :type location: str + :param properties: Required. The properties of the target resource. + :type properties: dict[str, any] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{object}'}, + } + + def __init__( + self, + *, + properties: Dict[str, Any], + location: Optional[str] = None, + **kwargs + ): + super(Target, self).__init__(**kwargs) + self.system_data = None + self.location = location + self.properties = properties + + +class TargetListResult(msrest.serialization.Model): + """Model that represents a list of Target resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Target resources. + :vartype value: list[~microsoft_azure_chaos.models.Target] + :ivar next_link: URL to retrieve the next page of Target resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Target]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class TargetReference(msrest.serialization.Model): + """Model that represents a reference to a Target in the selector. + + 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 type: Enum of the Target reference type. Has constant value: "ResourceId". + :vartype type: str + :param id: Required. String of the resource ID of a Target resource. + :type id: str + """ + + _validation = { + 'type': {'required': True, 'constant': True}, + 'id': {'required': True, 'pattern': r'^\/[Ss][Uu][Bb][Ss][Cc][Rr][Ii][Pp][Tt][Ii][Oo][Nn][Ss]\/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\/[Rr][Ee][Ss][Oo][Uu][Rr][Cc][Ee][Gg][Rr][Oo][Uu][Pp][Ss]\/[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]\/[Pp][Rr][Oo][Vv][Ii][Dd][Ee][Rr][Ss]\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+\/[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_\-\.]+\/[Pp][Rr][Oo][Vv][Ii][Dd][Ee][Rr][Ss]\/[Mm][Ii][Cc][Rr][Oo][Ss][Oo][Ff][Tt]\.[Cc][Hh][Aa][Oo][Ss]\/[Tt][Aa][Rr][Gg][Ee][Tt][Ss]\/[a-zA-Z0-9_\-\.]+$'}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + } + + type = "ResourceId" + + def __init__( + self, + *, + id: str, + **kwargs + ): + super(TargetReference, self).__init__(**kwargs) + self.id = id + + +class TargetType(Resource): + """Model that represents a Target Type resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata properties of the target type resource. + :vartype system_data: ~microsoft_azure_chaos.models.SystemData + :param location: Location of the Target Type resource. + :type location: str + :ivar display_name: Localized string of the display name. + :vartype display_name: str + :ivar description: Localized string of the description. + :vartype description: str + :ivar properties_schema: URL to retrieve JSON schema of the Target Type properties. + :vartype properties_schema: str + :ivar resource_types: List of resource types this Target Type can extend. + :vartype resource_types: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'display_name': {'readonly': True}, + 'description': {'readonly': True}, + 'properties_schema': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + 'resource_types': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'location': {'key': 'location', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'properties_schema': {'key': 'properties.propertiesSchema', 'type': 'str'}, + 'resource_types': {'key': 'properties.resourceTypes', 'type': '[str]'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + **kwargs + ): + super(TargetType, self).__init__(**kwargs) + self.system_data = None + self.location = location + self.display_name = None + self.description = None + self.properties_schema = None + self.resource_types = None + + +class TargetTypeListResult(msrest.serialization.Model): + """Model that represents a list of Target Type resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Target Type resources. + :vartype value: list[~microsoft_azure_chaos.models.TargetType] + :ivar next_link: URL to retrieve the next page of Target Type resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True, 'max_length': 2048, 'min_length': 0}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TargetType]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(TargetTypeListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py new file mode 100644 index 000000000000..14351e04a4bc --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/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 ._capabilities_operations import CapabilitiesOperations +from ._experiments_operations import ExperimentsOperations +from ._operations import Operations +from ._targets_operations import TargetsOperations +from ._target_types_operations import TargetTypesOperations +from ._capability_types_operations import CapabilityTypesOperations + +__all__ = [ + 'CapabilitiesOperations', + 'ExperimentsOperations', + 'Operations', + 'TargetsOperations', + 'TargetTypesOperations', + 'CapabilityTypesOperations', +] diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py new file mode 100644 index 000000000000..0f29e82c4270 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capabilities_operations.py @@ -0,0 +1,372 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CapabilitiesOperations(object): + """CapabilitiesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.CapabilityListResult"] + """Get a list of Capability resources that extend a Target resource.. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CapabilityListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.CapabilityListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CapabilityListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities'} # type: ignore + + def get( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + capability_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Capability" + """Get a Capability resource that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Capability, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Capability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Capability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Capability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + capability_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a Capability that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + capability_name, # type: str + capability, # type: "_models.Capability" + **kwargs # type: Any + ): + # type: (...) -> "_models.Capability" + """Create or update a Capability resource that extends a Target resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param capability_name: String that represents a Capability resource name. + :type capability_name: str + :param capability: Capability resource to be created or updated. + :type capability: ~microsoft_azure_chaos.models.Capability + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Capability, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Capability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Capability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityName': self._serialize.url("capability_name", capability_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(capability, 'Capability') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Capability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}/capabilities/{capabilityName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py new file mode 100644 index 000000000000..24835a99a222 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_capability_types_operations.py @@ -0,0 +1,191 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class CapabilityTypesOperations(object): + """CapabilityTypesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + location_name, # type: str + target_type_name, # type: str + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.CapabilityTypeListResult"] + """Get a list of Capability Type resources for given Target Type and location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CapabilityTypeListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.CapabilityTypeListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('CapabilityTypeListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes'} # type: ignore + + def get( + self, + location_name, # type: str + target_type_name, # type: str + capability_type_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.CapabilityType" + """Get a Capability Type resource for given Target Type and location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :param capability_type_name: String that represents a Capability Type resource name. + :type capability_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CapabilityType, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.CapabilityType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilityType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'capabilityTypeName': self._serialize.url("capability_type_name", capability_type_name, 'str', pattern=r'^[a-zA-Z0-9\-\.]+-\d\.\d$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CapabilityType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}/capabilityTypes/{capabilityTypeName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py new file mode 100644 index 000000000000..3fb3f1f8bc9a --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_experiments_operations.py @@ -0,0 +1,911 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ExperimentsOperations(object): + """ExperimentsOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_all( + self, + running=None, # type: Optional[bool] + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExperimentListResult"] + """Get a list of Experiment resources in a subscription. + + :param running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. + :type running: bool + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.ExperimentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if running is not None: + query_parameters['running'] = self._serialize.query("running", running, 'bool') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/experiments'} # type: ignore + + def list( + self, + resource_group_name, # type: str + running=None, # type: Optional[bool] + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExperimentListResult"] + """Get a list of Experiment resources in a resource group. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param running: Optional value that indicates whether to filter results based on if the + Experiment is currently running. If null, then the results will not be filtered. + :type running: bool + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.ExperimentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if running is not None: + query_parameters['running'] = self._serialize.query("running", running, 'bool') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + def get( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Experiment" + """Get a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Experiment, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Experiment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name, # type: str + experiment_name, # type: str + experiment, # type: "_models.Experiment" + **kwargs # type: Any + ): + # type: (...) -> "_models.Experiment" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(experiment, 'Experiment') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + def begin_create_or_update( + self, + resource_group_name, # type: str + experiment_name, # type: str + experiment, # type: "_models.Experiment" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Experiment"] + """Create or update a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param experiment: Experiment resource to be created or updated. + :type experiment: ~microsoft_azure_chaos.models.Experiment + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Experiment or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_azure_chaos.models.Experiment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Experiment"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + experiment=experiment, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Experiment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}'} # type: ignore + + def _cancel_initial( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ExperimentCancelOperationResult" + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentCancelOperationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self._cancel_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentCancelOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _cancel_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel'} # type: ignore + + def begin_cancel( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.ExperimentCancelOperationResult"] + """Cancel a running Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ExperimentCancelOperationResult or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~microsoft_azure_chaos.models.ExperimentCancelOperationResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentCancelOperationResult"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._cancel_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ExperimentCancelOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_cancel.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel'} # type: ignore + + def start( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ExperimentStartOperationResult" + """Start a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentStartOperationResult, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentStartOperationResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStartOperationResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.start.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentStartOperationResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start'} # type: ignore + + def list_all_statuses( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExperimentStatusListResult"] + """Get a list of statuses of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentStatusListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.ExperimentStatusListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStatusListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all_statuses.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentStatusListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_all_statuses.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses'} # type: ignore + + def get_status( + self, + resource_group_name, # type: str + experiment_name, # type: str + status_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ExperimentStatus" + """Get a status of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param status_id: GUID that represents a Experiment status. + :type status_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentStatus, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentStatus + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentStatus"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_status.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'statusId': self._serialize.url("status_id", status_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses/{statusId}'} # type: ignore + + def list_execution_details( + self, + resource_group_name, # type: str + experiment_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.ExperimentExecutionDetailsListResult"] + """Get a list of execution details of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ExperimentExecutionDetailsListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.ExperimentExecutionDetailsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentExecutionDetailsListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_execution_details.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ExperimentExecutionDetailsListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_execution_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails'} # type: ignore + + def get_execution_details( + self, + resource_group_name, # type: str + experiment_name, # type: str + execution_details_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.ExperimentExecutionDetails" + """Get an execution detail of a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. + :type experiment_name: str + :param execution_details_id: GUID that represents a Experiment execution detail. + :type execution_details_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ExperimentExecutionDetails, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.ExperimentExecutionDetails + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentExecutionDetails"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get_execution_details.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'experimentName': self._serialize.url("experiment_name", experiment_name, 'str', min_length=1, pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'executionDetailsId': self._serialize.url("execution_details_id", execution_details_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ExperimentExecutionDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_execution_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py new file mode 100644 index 000000000000..f785532c90e0 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.OperationListResult"] + """Get a list all available Operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_all.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_all.metadata = {'url': '/providers/Microsoft.Chaos/operations'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py new file mode 100644 index 000000000000..c9fa1c2ca892 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_target_types_operations.py @@ -0,0 +1,183 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TargetTypesOperations(object): + """TargetTypesOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + location_name, # type: str + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TargetTypeListResult"] + """Get a list of Target Type resources for given location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TargetTypeListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.TargetTypeListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetTypeListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('TargetTypeListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes'} # type: ignore + + def get( + self, + location_name, # type: str + target_type_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.TargetType" + """Get a Target Type resources for given location. + + :param location_name: String that represents a Location resource name. + :type location_name: str + :param target_type_name: String that represents a Target Type resource name. + :type target_type_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TargetType, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.TargetType + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetType"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'locationName': self._serialize.url("location_name", location_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetTypeName': self._serialize.url("target_type_name", target_type_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TargetType', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{locationName}/targetTypes/{targetTypeName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py new file mode 100644 index 000000000000..3243564aedbf --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_targets_operations.py @@ -0,0 +1,356 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class TargetsOperations(object): + """TargetsOperations 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: ~microsoft_azure_chaos.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + continuation_token_parameter=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.TargetListResult"] + """Get a list of Target resources that extend a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param continuation_token_parameter: String that sets the continuation token. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either TargetListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~microsoft_azure_chaos.models.TargetListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.TargetListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if continuation_token_parameter is not None: + query_parameters['continuationToken'] = self._serialize.query("continuation_token_parameter", continuation_token_parameter, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('TargetListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets'} # type: ignore + + def get( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Target" + """Get a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Target, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Target + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Target"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Target', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Delete a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore + + def create_or_update( + self, + resource_group_name, # type: str + parent_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource_name, # type: str + target_name, # type: str + target, # type: "_models.Target" + **kwargs # type: Any + ): + # type: (...) -> "_models.Target" + """Create or update a Target resource that extends a tracked regional resource. + + :param resource_group_name: String that represents an Azure resource group. + :type resource_group_name: str + :param parent_provider_namespace: String that represents a resource provider namespace. + :type parent_provider_namespace: str + :param parent_resource_type: String that represents a resource type. + :type parent_resource_type: str + :param parent_resource_name: String that represents a resource name. + :type parent_resource_name: str + :param target_name: String that represents a Target resource name. + :type target_name: str + :param target: Target resource to be created or updated. + :type target: ~microsoft_azure_chaos.models.Target + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Target, or the result of cls(response) + :rtype: ~microsoft_azure_chaos.models.Target + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Target"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-09-15-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', pattern=r'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$'), + 'parentProviderNamespace': self._serialize.url("parent_provider_namespace", parent_provider_namespace, 'str', pattern=r'^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'parentResourceName': self._serialize.url("parent_resource_name", parent_resource_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + 'targetName': self._serialize.url("target_name", target_name, 'str', pattern=r'^[a-zA-Z0-9_\-\.]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(target, 'Target') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Target', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{parentProviderNamespace}/{parentResourceType}/{parentResourceName}/providers/Microsoft.Chaos/targets/{targetName}'} # type: ignore diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/py.typed b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml b/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml new file mode 100644 index 000000000000..7b46eafb8d3a --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +package_name = "azure-mgmt-chaos" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Chaos Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true diff --git a/sdk/chaos/azure-mgmt-chaos/setup.cfg b/sdk/chaos/azure-mgmt-chaos/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/chaos/azure-mgmt-chaos/setup.py b/sdk/chaos/azure-mgmt-chaos/setup.py new file mode 100644 index 000000000000..19ab65be205d --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/setup.py @@ -0,0 +1,90 @@ +#!/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-chaos" +PACKAGE_PPRINT_NAME = "Chaos Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + '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.2.0,<2.0.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) diff --git a/sdk/chaos/ci.yml b/sdk/chaos/ci.yml new file mode 100644 index 000000000000..fa30d2a9d064 --- /dev/null +++ b/sdk/chaos/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/chaos/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/chaos/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: chaos + Artifacts: + - name: azure-mgmt-chaos + safeName: azuremgmtchaos diff --git a/shared_requirements.txt b/shared_requirements.txt index b7e7cce6792f..e46f1a9dac96 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -355,3 +355,4 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-fluidrelay msrest>=0.6.21 #override azure-ai-language-conversations azure-core<2.0.0,>=1.19.0 #override azure-ai-language-conversations msrest>=0.6.21 +#override azure-mgmt-chaos msrest>=0.6.21