diff --git a/sdk/chaos/azure-mgmt-chaos/_meta.json b/sdk/chaos/azure-mgmt-chaos/_meta.json index 079f23a029db..d00787dbeb19 100644 --- a/sdk/chaos/azure-mgmt-chaos/_meta.json +++ b/sdk/chaos/azure-mgmt-chaos/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e680f9bf4f154ec427ba7feac432ed8efd9665d0", + "commit": "fa443ab78b3ad98066ea5a60bea7d50cc20ce426", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.6.0", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/chaos/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.6.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/chaos/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/chaos/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py index e43d5ab0241f..b5421be86b24 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_chaos_management_client.py @@ -19,6 +19,7 @@ CapabilitiesOperations, CapabilityTypesOperations, ExperimentsOperations, + OperationStatusesOperations, Operations, TargetTypesOperations, TargetsOperations, @@ -29,7 +30,7 @@ from azure.core.credentials import TokenCredential -class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Chaos Management Client. :ivar capabilities: CapabilitiesOperations operations @@ -38,6 +39,8 @@ class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keywo :vartype capability_types: azure.mgmt.chaos.operations.CapabilityTypesOperations :ivar experiments: ExperimentsOperations operations :vartype experiments: azure.mgmt.chaos.operations.ExperimentsOperations + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: azure.mgmt.chaos.operations.OperationStatusesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.chaos.operations.Operations :ivar target_types: TargetTypesOperations operations @@ -50,9 +53,11 @@ class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-15-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -76,6 +81,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.target_types = TargetTypesOperations(self._client, self._config, self._serialize, self._deserialize) self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py index 7eee35c4a03d..1d1b77f7ea2a 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_configuration.py @@ -29,14 +29,14 @@ class ChaosManagementClientConfiguration(Configuration): # pylint: disable=too- :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: GUID that represents an Azure subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-15-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ChaosManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-15-preview") + api_version: str = kwargs.pop("api_version", "2023-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_serialization.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_serialization.py index 842ae727fbbc..4bae2292227b 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_serialization.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_serialization.py @@ -662,8 +662,9 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -741,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -749,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -891,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -903,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -950,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_vendor.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_vendor.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py index 7a749d028746..9cf33092d41b 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b7" +VERSION = "1.0.0b5" diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py index dd22e0db0248..8f4f1fa951bb 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_chaos_management_client.py @@ -19,6 +19,7 @@ CapabilitiesOperations, CapabilityTypesOperations, ExperimentsOperations, + OperationStatusesOperations, Operations, TargetTypesOperations, TargetsOperations, @@ -29,7 +30,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keyword +class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Chaos Management Client. :ivar capabilities: CapabilitiesOperations operations @@ -38,6 +39,8 @@ class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keywo :vartype capability_types: azure.mgmt.chaos.aio.operations.CapabilityTypesOperations :ivar experiments: ExperimentsOperations operations :vartype experiments: azure.mgmt.chaos.aio.operations.ExperimentsOperations + :ivar operation_statuses: OperationStatusesOperations operations + :vartype operation_statuses: azure.mgmt.chaos.aio.operations.OperationStatusesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.chaos.aio.operations.Operations :ivar target_types: TargetTypesOperations operations @@ -50,9 +53,11 @@ class ChaosManagementClient: # pylint: disable=client-accepts-api-version-keywo :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2023-04-15-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( @@ -76,6 +81,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operation_statuses = OperationStatusesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.target_types = TargetTypesOperations(self._client, self._config, self._serialize, self._deserialize) self.targets = TargetsOperations(self._client, self._config, self._serialize, self._deserialize) 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 index 8a7f7c0ea16e..4c77e647e702 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/_configuration.py @@ -29,14 +29,14 @@ class ChaosManagementClientConfiguration(Configuration): # pylint: disable=too- :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: GUID that represents an Azure subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-04-15-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ChaosManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-04-15-preview") + api_version: str = kwargs.pop("api_version", "2023-11-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") 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 index bae252b95e54..531fb369a6b5 100644 --- 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 @@ -9,6 +9,7 @@ from ._capabilities_operations import CapabilitiesOperations from ._capability_types_operations import CapabilityTypesOperations from ._experiments_operations import ExperimentsOperations +from ._operation_statuses_operations import OperationStatusesOperations from ._operations import Operations from ._target_types_operations import TargetTypesOperations from ._targets_operations import TargetsOperations @@ -21,6 +22,7 @@ "CapabilitiesOperations", "CapabilityTypesOperations", "ExperimentsOperations", + "OperationStatusesOperations", "Operations", "TargetTypesOperations", "TargetsOperations", 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 index dca9e6282f72..e8f2c44f2541 100644 --- 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 @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -21,11 +21,13 @@ ) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request @@ -33,12 +35,11 @@ build_cancel_request, build_create_or_update_request, build_delete_request, - build_get_execution_details_request, + build_execution_details_request, + build_get_execution_request, build_get_request, - build_get_status_request, + build_list_all_executions_request, build_list_all_request, - build_list_all_statuses_request, - build_list_execution_details_request, build_list_request, build_start_request, build_update_request, @@ -260,21 +261,9 @@ async def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments" } - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements + async def _delete_initial( # pylint: disable=inconsistent-return-statements 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. Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :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: - """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -294,7 +283,7 @@ async def delete( # pylint: disable=inconsistent-return-statements experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -308,7 +297,7 @@ async def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 204]: + 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, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -316,7 +305,72 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = { + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } @@ -382,8 +436,76 @@ async def get(self, resource_group_name: str, experiment_name: str, **kwargs: An "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } + async def _create_or_update_initial( + self, resource_group_name: str, experiment_name: str, experiment: Union[_models.Experiment, IO], **kwargs: Any + ) -> _models.Experiment: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(experiment, (IOBase, bytes)): + _content = experiment + else: + _json = self._serialize.body(experiment, "Experiment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Experiment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Experiment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -391,7 +513,7 @@ async def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -404,13 +526,21 @@ async def create_or_update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -418,7 +548,7 @@ async def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -431,15 +561,23 @@ async def create_or_update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, experiment_name: str, experiment: Union[_models.Experiment, IO], **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -453,10 +591,76 @@ async def create_or_update( Default value is None. :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + 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, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Experiment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + async def _update_initial( + self, + resource_group_name: str, + experiment_name: str, + experiment: Union[_models.ExperimentUpdate, IO], + **kwargs: Any + ) -> _models.Experiment: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -478,9 +682,9 @@ async def create_or_update( if isinstance(experiment, (IOBase, bytes)): _content = experiment else: - _json = self._serialize.body(experiment, "Experiment") + _json = self._serialize.body(experiment, "ExperimentUpdate") - request = build_create_or_update_request( + request = build_update_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, @@ -488,7 +692,7 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -502,7 +706,7 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -514,12 +718,12 @@ async def create_or_update( return deserialized - create_or_update.metadata = { + _update_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } @overload - async def update( + async def begin_update( self, resource_group_name: str, experiment_name: str, @@ -527,7 +731,7 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -540,13 +744,21 @@ async def update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( + async def begin_update( self, resource_group_name: str, experiment_name: str, @@ -554,7 +766,7 @@ async def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -567,19 +779,27 @@ async def update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def begin_update( self, resource_group_name: str, experiment_name: str, experiment: Union[_models.ExperimentUpdate, IO], **kwargs: Any - ) -> _models.Experiment: + ) -> AsyncLROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -593,10 +813,71 @@ async def update( Default value is None. :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + experiment=experiment, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Experiment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + async def _cancel_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -605,30 +886,18 @@ async def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(experiment, (IOBase, bytes)): - _content = experiment - else: - _json = self._serialize.body(experiment, "ExperimentUpdate") + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_update_request( + request = build_cancel_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], + template_url=self._cancel_initial.metadata["url"], headers=_headers, params=_params, ) @@ -642,26 +911,20 @@ async def update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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, pipeline_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 + return cls(pipeline_response, None, {}) - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" } @distributed_trace_async - async def cancel( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> _models.ExperimentCancelOperationResult: + async def begin_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Cancel a running Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -669,10 +932,65 @@ async def cancel( :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExperimentCancelOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentCancelOperationResult + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._cancel_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + } + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -685,14 +1003,14 @@ async def cancel( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentCancelOperationResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + request = build_start_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata["url"], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -711,21 +1029,15 @@ async def cancel( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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 + return cls(pipeline_response, None, {}) - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + _start_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" } @distributed_trace_async - async def start( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> _models.ExperimentStartOperationResult: + async def begin_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Start a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -733,79 +1045,82 @@ async def start( :param experiment_name: String that represents a Experiment resource name. Required. :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: ~azure.mgmt.chaos.models.ExperimentStartOperationResult + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStartOperationResult] = kwargs.pop("cls", None) - - request = build_start_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.start.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentStartOperationResult", pipeline_response) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._start_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - return deserialized + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, 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, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - start.metadata = { + begin_start.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" } @distributed_trace - def list_all_statuses( + def list_all_executions( self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExperimentStatus"]: - """Get a list of statuses of a Experiment resource. + ) -> AsyncIterable["_models.ExperimentExecution"]: + """Get a list of executions of an Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :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 ExperimentStatus or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ExperimentStatus] + :return: An iterator like instance of either ExperimentExecution or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStatusListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ExperimentExecutionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -818,12 +1133,12 @@ def list_all_statuses( def prepare_request(next_link=None): if not next_link: - request = build_list_all_statuses_request( + request = build_list_all_executions_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all_statuses.metadata["url"], + template_url=self.list_all_executions.metadata["url"], headers=_headers, params=_params, ) @@ -849,7 +1164,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentStatusListResult", pipeline_response) + deserialized = self._deserialize("ExperimentExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -873,25 +1188,25 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_all_statuses.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses" + list_all_executions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions" } @distributed_trace_async - 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. + async def get_execution( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecution: + """Get an execution of an Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str - :param status_id: GUID that represents a Experiment status. Required. - :type status_id: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_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: ~azure.mgmt.chaos.models.ExperimentStatus + :return: ExperimentExecution or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.ExperimentExecution :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -906,15 +1221,15 @@ async def get_status( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.ExperimentExecution] = kwargs.pop("cls", None) - request = build_get_status_request( + request = build_get_execution_request( resource_group_name=resource_group_name, experiment_name=experiment_name, - status_id=status_id, + execution_id=execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_status.metadata["url"], + template_url=self.get_execution.metadata["url"], headers=_headers, params=_params, ) @@ -933,122 +1248,29 @@ async def get_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExperimentStatus", pipeline_response) + deserialized = self._deserialize("ExperimentExecution", 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}" - } - - @distributed_trace - def list_execution_details( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExperimentExecutionDetails"]: - """Get a list of execution details of a Experiment resource. - - :param resource_group_name: String that represents an Azure resource group. Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :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 ExperimentExecutionDetails or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.ExperimentExecutionDetails] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentExecutionDetailsListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_execution_details_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_execution_details.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentExecutionDetailsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_execution_details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails" + get_execution.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}" } @distributed_trace_async - async def get_execution_details( - self, resource_group_name: str, experiment_name: str, execution_details_id: str, **kwargs: Any + async def execution_details( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any ) -> _models.ExperimentExecutionDetails: - """Get an execution detail of a Experiment resource. + """Execution details of an experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str - :param execution_details_id: GUID that represents a Experiment execution detail. Required. - :type execution_details_id: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_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: ~azure.mgmt.chaos.models.ExperimentExecutionDetails @@ -1068,13 +1290,13 @@ async def get_execution_details( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExperimentExecutionDetails] = kwargs.pop("cls", None) - request = build_get_execution_details_request( + request = build_execution_details_request( resource_group_name=resource_group_name, experiment_name=experiment_name, - execution_details_id=execution_details_id, + execution_id=execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_execution_details.metadata["url"], + template_url=self.execution_details.metadata["url"], headers=_headers, params=_params, ) @@ -1100,6 +1322,6 @@ async def get_execution_details( return deserialized - get_execution_details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}" + execution_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails" } diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py new file mode 100644 index 000000000000..a5274987e94f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_operation_statuses_operations.py @@ -0,0 +1,113 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operation_statuses_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OperationStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`operation_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, async_operation_id: str, **kwargs: Any) -> _models.OperationStatus: + """Get the status of a long running azure asynchronous operation. + + :param location: The region name of operation. Required. + :type location: str + :param async_operation_id: The operation Id. Required. + :type async_operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatus or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.OperationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) + + request = build_get_request( + location=location, + async_operation_id=async_operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationsStatuses/{asyncOperationId}" + } 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 index 27cc462a1574..9a96863d5947 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/__init__.py @@ -6,15 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 CapabilityTypePropertiesRuntimeProperties +from ._models_py3 import ChaosExperimentAction +from ._models_py3 import ChaosExperimentBranch +from ._models_py3 import ChaosExperimentStep +from ._models_py3 import ChaosTargetFilter +from ._models_py3 import ChaosTargetListSelector +from ._models_py3 import ChaosTargetQuerySelector +from ._models_py3 import ChaosTargetSelector +from ._models_py3 import ChaosTargetSimpleFilter +from ._models_py3 import ChaosTargetSimpleFilterParameters from ._models_py3 import ContinuousAction from ._models_py3 import DelayAction from ._models_py3 import DiscreteAction @@ -22,30 +29,23 @@ from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Experiment -from ._models_py3 import ExperimentCancelOperationResult +from ._models_py3 import ExperimentExecution from ._models_py3 import ExperimentExecutionActionTargetDetailsError from ._models_py3 import ExperimentExecutionActionTargetDetailsProperties from ._models_py3 import ExperimentExecutionDetails -from ._models_py3 import ExperimentExecutionDetailsListResult +from ._models_py3 import ExperimentExecutionDetailsProperties from ._models_py3 import ExperimentExecutionDetailsPropertiesRunInformation +from ._models_py3 import ExperimentExecutionListResult +from ._models_py3 import ExperimentExecutionProperties from ._models_py3 import ExperimentListResult -from ._models_py3 import ExperimentStartOperationResult -from ._models_py3 import ExperimentStatus -from ._models_py3 import ExperimentStatusListResult from ._models_py3 import ExperimentUpdate -from ._models_py3 import Filter from ._models_py3 import KeyValuePair -from ._models_py3 import ListSelector from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult -from ._models_py3 import QuerySelector +from ._models_py3 import OperationStatus from ._models_py3 import Resource from ._models_py3 import ResourceIdentity -from ._models_py3 import Selector -from ._models_py3 import SimpleFilter -from ._models_py3 import SimpleFilterParameters -from ._models_py3 import Step from ._models_py3 import StepStatus from ._models_py3 import SystemData from ._models_py3 import Target @@ -60,6 +60,7 @@ from ._chaos_management_client_enums import CreatedByType from ._chaos_management_client_enums import FilterType from ._chaos_management_client_enums import Origin +from ._chaos_management_client_enums import ProvisioningState from ._chaos_management_client_enums import ResourceIdentityType from ._chaos_management_client_enums import SelectorType from ._chaos_management_client_enums import TargetReferenceType @@ -68,15 +69,22 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "Action", "ActionStatus", - "Branch", "BranchStatus", "Capability", "CapabilityListResult", "CapabilityType", "CapabilityTypeListResult", "CapabilityTypePropertiesRuntimeProperties", + "ChaosExperimentAction", + "ChaosExperimentBranch", + "ChaosExperimentStep", + "ChaosTargetFilter", + "ChaosTargetListSelector", + "ChaosTargetQuerySelector", + "ChaosTargetSelector", + "ChaosTargetSimpleFilter", + "ChaosTargetSimpleFilterParameters", "ContinuousAction", "DelayAction", "DiscreteAction", @@ -84,30 +92,23 @@ "ErrorDetail", "ErrorResponse", "Experiment", - "ExperimentCancelOperationResult", + "ExperimentExecution", "ExperimentExecutionActionTargetDetailsError", "ExperimentExecutionActionTargetDetailsProperties", "ExperimentExecutionDetails", - "ExperimentExecutionDetailsListResult", + "ExperimentExecutionDetailsProperties", "ExperimentExecutionDetailsPropertiesRunInformation", + "ExperimentExecutionListResult", + "ExperimentExecutionProperties", "ExperimentListResult", - "ExperimentStartOperationResult", - "ExperimentStatus", - "ExperimentStatusListResult", "ExperimentUpdate", - "Filter", "KeyValuePair", - "ListSelector", "Operation", "OperationDisplay", "OperationListResult", - "QuerySelector", + "OperationStatus", "Resource", "ResourceIdentity", - "Selector", - "SimpleFilter", - "SimpleFilterParameters", - "Step", "StepStatus", "SystemData", "Target", @@ -121,6 +122,7 @@ "CreatedByType", "FilterType", "Origin", + "ProvisioningState", "ResourceIdentityType", "SelectorType", "TargetReferenceType", diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py index 211ebcf4e38c..8a4d65ccee92 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/models/_chaos_management_client_enums.py @@ -41,6 +41,17 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_SYSTEM = "user,system" +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current provisioning state for a given Azure Chaos resource.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + + class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """String of the resource identity type.""" 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 index 88d106524185..835953ce1ec0 100644 --- 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 @@ -17,42 +17,6 @@ from .. import models as _models -class Action(_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. - - :ivar type: Enum that discriminates between action models. Required. - :vartype type: str - :ivar name: String that represents a Capability URN. Required. - :vartype name: str - """ - - _validation = { - "type": {"required": True}, - "name": {"required": True, "max_length": 2048}, - } - - _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: Any) -> None: - """ - :keyword name: String that represents a Capability URN. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.name = name - - class ActionStatus(_serialization.Model): """Model that represents the an action and its status. @@ -102,39 +66,6 @@ def __init__(self, **kwargs: Any) -> None: self.targets = None -class Branch(_serialization.Model): - """Model that represents a branch in the step. - - All required parameters must be populated in order to send to Azure. - - :ivar name: String of the branch name. Required. - :vartype name: str - :ivar actions: List of actions. Required. - :vartype actions: list[~azure.mgmt.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["_models.Action"], **kwargs: Any) -> None: - """ - :keyword name: String of the branch name. Required. - :paramtype name: str - :keyword actions: List of actions. Required. - :paramtype actions: list[~azure.mgmt.chaos.models.Action] - """ - super().__init__(**kwargs) - self.name = name - self.actions = actions - - class BranchStatus(_serialization.Model): """Model that represents the a list of actions and action statuses. @@ -458,8 +389,11 @@ def __init__(self, **kwargs: Any) -> None: self.kind = None -class ContinuousAction(Action): - """Model that represents a continuous action. +class ChaosExperimentAction(_serialization.Model): + """Model that represents the base action model. 9 total per experiment. + + 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. @@ -467,211 +401,579 @@ class ContinuousAction(Action): :vartype type: str :ivar name: String that represents a Capability URN. Required. :vartype name: str - :ivar duration: ISO8601 formatted string that represents a duration. Required. - :vartype duration: ~datetime.timedelta - :ivar parameters: List of key value pairs. Required. - :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :ivar selector_id: String that represents a selector. Required. - :vartype selector_id: str """ _validation = { "type": {"required": True}, "name": {"required": True, "max_length": 2048}, - "duration": {"required": True}, - "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": "duration"}, - "parameters": {"key": "parameters", "type": "[KeyValuePair]"}, - "selector_id": {"key": "selectorId", "type": "str"}, } - def __init__( - self, - *, - name: str, - duration: datetime.timedelta, - parameters: List["_models.KeyValuePair"], - selector_id: str, - **kwargs: Any - ) -> None: + _subtype_map = {"type": {"continuous": "ContinuousAction", "delay": "DelayAction", "discrete": "DiscreteAction"}} + + def __init__(self, *, name: str, **kwargs: Any) -> None: """ :keyword name: String that represents a Capability URN. Required. :paramtype name: str - :keyword duration: ISO8601 formatted string that represents a duration. Required. - :paramtype duration: ~datetime.timedelta - :keyword parameters: List of key value pairs. Required. - :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :keyword selector_id: String that represents a selector. Required. - :paramtype selector_id: str """ - super().__init__(name=name, **kwargs) - self.type: str = "continuous" - self.duration = duration - self.parameters = parameters - self.selector_id = selector_id + super().__init__(**kwargs) + self.type: Optional[str] = None + self.name = name -class DelayAction(Action): - """Model that represents a delay action. +class ChaosExperimentBranch(_serialization.Model): + """Model that represents a branch in the step. 9 total per experiment. All required parameters must be populated in order to send to Azure. - :ivar type: Enum that discriminates between action models. Required. - :vartype type: str - :ivar name: String that represents a Capability URN. Required. + :ivar name: String of the branch name. Required. :vartype name: str - :ivar duration: ISO8601 formatted string that represents a duration. Required. - :vartype duration: ~datetime.timedelta + :ivar actions: List of actions. Required. + :vartype actions: list[~azure.mgmt.chaos.models.ChaosExperimentAction] """ _validation = { - "type": {"required": True}, - "name": {"required": True, "max_length": 2048}, - "duration": {"required": True}, + "name": {"required": True, "min_length": 1}, + "actions": {"required": True, "max_items": 9, "min_items": 1}, } _attribute_map = { - "type": {"key": "type", "type": "str"}, "name": {"key": "name", "type": "str"}, - "duration": {"key": "duration", "type": "duration"}, + "actions": {"key": "actions", "type": "[ChaosExperimentAction]"}, } - def __init__(self, *, name: str, duration: datetime.timedelta, **kwargs: Any) -> None: + def __init__(self, *, name: str, actions: List["_models.ChaosExperimentAction"], **kwargs: Any) -> None: """ - :keyword name: String that represents a Capability URN. Required. + :keyword name: String of the branch name. Required. :paramtype name: str - :keyword duration: ISO8601 formatted string that represents a duration. Required. - :paramtype duration: ~datetime.timedelta + :keyword actions: List of actions. Required. + :paramtype actions: list[~azure.mgmt.chaos.models.ChaosExperimentAction] """ - super().__init__(name=name, **kwargs) - self.type: str = "delay" - self.duration = duration + super().__init__(**kwargs) + self.name = name + self.actions = actions -class DiscreteAction(Action): - """Model that represents a discrete action. +class ChaosExperimentStep(_serialization.Model): + """Model that represents a step in the Experiment resource. All required parameters must be populated in order to send to Azure. - :ivar type: Enum that discriminates between action models. Required. - :vartype type: str - :ivar name: String that represents a Capability URN. Required. + :ivar name: String of the step name. Required. :vartype name: str - :ivar parameters: List of key value pairs. Required. - :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :ivar selector_id: String that represents a selector. Required. - :vartype selector_id: str + :ivar branches: List of branches. Required. + :vartype branches: list[~azure.mgmt.chaos.models.ChaosExperimentBranch] """ _validation = { - "type": {"required": True}, - "name": {"required": True, "max_length": 2048}, - "parameters": {"required": True}, - "selector_id": {"required": True, "min_length": 1}, + "name": {"required": True, "min_length": 1}, + "branches": {"required": True, "max_items": 9, "min_items": 1}, } _attribute_map = { - "type": {"key": "type", "type": "str"}, "name": {"key": "name", "type": "str"}, - "parameters": {"key": "parameters", "type": "[KeyValuePair]"}, - "selector_id": {"key": "selectorId", "type": "str"}, + "branches": {"key": "branches", "type": "[ChaosExperimentBranch]"}, } - def __init__(self, *, name: str, parameters: List["_models.KeyValuePair"], selector_id: str, **kwargs: Any) -> None: + def __init__(self, *, name: str, branches: List["_models.ChaosExperimentBranch"], **kwargs: Any) -> None: """ - :keyword name: String that represents a Capability URN. Required. + :keyword name: String of the step name. Required. :paramtype name: str - :keyword parameters: List of key value pairs. Required. - :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] - :keyword selector_id: String that represents a selector. Required. - :paramtype selector_id: str + :keyword branches: List of branches. Required. + :paramtype branches: list[~azure.mgmt.chaos.models.ChaosExperimentBranch] """ - super().__init__(name=name, **kwargs) - self.type: str = "discrete" - self.parameters = parameters - self.selector_id = selector_id + super().__init__(**kwargs) + self.name = name + self.branches = branches -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. +class ChaosTargetFilter(_serialization.Model): + """Model that represents available filter types that can be applied to a targets list. - Variables are only populated by the server, and will be ignored when sending a request. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ChaosTargetSimpleFilter - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON + All required parameters must be populated in order to send to Azure. + + :ivar type: Enum that discriminates between filter types. Currently only ``Simple`` type is + supported. Required. "Simple" + :vartype type: str or ~azure.mgmt.chaos.models.FilterType """ _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, } + _subtype_map = {"type": {"Simple": "ChaosTargetSimpleFilter"}} + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.info = None + self.type: Optional[str] = None -class ErrorDetail(_serialization.Model): - """The error detail. +class ChaosTargetSelector(_serialization.Model): + """Model that represents a selector in the Experiment resource. - Variables are only populated by the server, and will be ignored when sending a request. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ChaosTargetListSelector, ChaosTargetQuerySelector - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.chaos.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.chaos.models.ErrorAdditionalInfo] + All required parameters must be populated in order to send to Azure. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". + :vartype type: str or ~azure.mgmt.chaos.models.SelectorType + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter """ _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, + "type": {"required": True}, + "id": {"required": True, "min_length": 1}, } _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]"}, + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "filter": {"key": "filter", "type": "ChaosTargetFilter"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + _subtype_map = {"type": {"List": "ChaosTargetListSelector", "Query": "ChaosTargetQuerySelector"}} + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + additional_properties: Optional[Dict[str, Any]] = None, + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword id: String of the selector ID. Required. + :paramtype id: str + :keyword filter: Model that represents available filter types that can be applied to a targets + list. + :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.additional_properties = additional_properties + self.type: Optional[str] = None + self.id = id + self.filter = filter -class ErrorResponse(_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.). +class ChaosTargetListSelector(ChaosTargetSelector): + """Model that represents a list selector. + + All required parameters must be populated in order to send to Azure. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". + :vartype type: str or ~azure.mgmt.chaos.models.SelectorType + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :ivar targets: List of Target references. Required. + :vartype targets: list[~azure.mgmt.chaos.models.TargetReference] + """ + + _validation = { + "type": {"required": True}, + "id": {"required": True, "min_length": 1}, + "targets": {"required": True, "max_items": 50, "min_items": 1}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "filter": {"key": "filter", "type": "ChaosTargetFilter"}, + "targets": {"key": "targets", "type": "[TargetReference]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + targets: List["_models.TargetReference"], + additional_properties: Optional[Dict[str, Any]] = None, + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword id: String of the selector ID. Required. + :paramtype id: str + :keyword filter: Model that represents available filter types that can be applied to a targets + list. + :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :keyword targets: List of Target references. Required. + :paramtype targets: list[~azure.mgmt.chaos.models.TargetReference] + """ + super().__init__(additional_properties=additional_properties, id=id, filter=filter, **kwargs) + self.type: str = "List" + self.targets = targets + + +class ChaosTargetQuerySelector(ChaosTargetSelector): + """Model that represents a query selector. + + All required parameters must be populated in order to send to Azure. + + :ivar additional_properties: Unmatched properties from the message are deserialized to this + collection. + :vartype additional_properties: dict[str, any] + :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". + :vartype type: str or ~azure.mgmt.chaos.models.SelectorType + :ivar id: String of the selector ID. Required. + :vartype id: str + :ivar filter: Model that represents available filter types that can be applied to a targets + list. + :vartype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :ivar query_string: Azure Resource Graph (ARG) Query Language query for target resources. + Required. + :vartype query_string: str + :ivar subscription_ids: Subscription id list to scope resource query. Required. + :vartype subscription_ids: list[str] + """ + + _validation = { + "type": {"required": True}, + "id": {"required": True, "min_length": 1}, + "query_string": {"required": True}, + "subscription_ids": {"required": True, "min_items": 1}, + } + + _attribute_map = { + "additional_properties": {"key": "", "type": "{object}"}, + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "filter": {"key": "filter", "type": "ChaosTargetFilter"}, + "query_string": {"key": "queryString", "type": "str"}, + "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + query_string: str, + subscription_ids: List[str], + additional_properties: Optional[Dict[str, Any]] = None, + filter: Optional["_models.ChaosTargetFilter"] = None, # pylint: disable=redefined-builtin + **kwargs: Any + ) -> None: + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword id: String of the selector ID. Required. + :paramtype id: str + :keyword filter: Model that represents available filter types that can be applied to a targets + list. + :paramtype filter: ~azure.mgmt.chaos.models.ChaosTargetFilter + :keyword query_string: Azure Resource Graph (ARG) Query Language query for target resources. + Required. + :paramtype query_string: str + :keyword subscription_ids: Subscription id list to scope resource query. Required. + :paramtype subscription_ids: list[str] + """ + super().__init__(additional_properties=additional_properties, id=id, filter=filter, **kwargs) + self.type: str = "Query" + self.query_string = query_string + self.subscription_ids = subscription_ids + + +class ChaosTargetSimpleFilter(ChaosTargetFilter): + """Model that represents a simple target filter. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Enum that discriminates between filter types. Currently only ``Simple`` type is + supported. Required. "Simple" + :vartype type: str or ~azure.mgmt.chaos.models.FilterType + :ivar parameters: Model that represents the Simple filter parameters. + :vartype parameters: ~azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters + """ + + _validation = { + "type": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "parameters": {"key": "parameters", "type": "ChaosTargetSimpleFilterParameters"}, + } + + def __init__( + self, *, parameters: Optional["_models.ChaosTargetSimpleFilterParameters"] = None, **kwargs: Any + ) -> None: + """ + :keyword parameters: Model that represents the Simple filter parameters. + :paramtype parameters: ~azure.mgmt.chaos.models.ChaosTargetSimpleFilterParameters + """ + super().__init__(**kwargs) + self.type: str = "Simple" + self.parameters = parameters + + +class ChaosTargetSimpleFilterParameters(_serialization.Model): + """Model that represents the Simple filter parameters. + + :ivar zones: List of Azure availability zones to filter targets by. + :vartype zones: list[str] + """ + + _attribute_map = { + "zones": {"key": "zones", "type": "[str]"}, + } + + def __init__(self, *, zones: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword zones: List of Azure availability zones to filter targets by. + :paramtype zones: list[str] + """ + super().__init__(**kwargs) + self.zones = zones + + +class ContinuousAction(ChaosExperimentAction): + """Model that represents a continuous action. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Enum that discriminates between action models. Required. + :vartype type: str + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar duration: ISO8601 formatted string that represents a duration. Required. + :vartype duration: ~datetime.timedelta + :ivar parameters: List of key value pairs. Required. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar selector_id: String that represents a selector. Required. + :vartype selector_id: str + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True, "max_length": 2048}, + "duration": {"required": True}, + "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": "duration"}, + "parameters": {"key": "parameters", "type": "[KeyValuePair]"}, + "selector_id": {"key": "selectorId", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + duration: datetime.timedelta, + parameters: List["_models.KeyValuePair"], + selector_id: str, + **kwargs: Any + ) -> None: + """ + :keyword name: String that represents a Capability URN. Required. + :paramtype name: str + :keyword duration: ISO8601 formatted string that represents a duration. Required. + :paramtype duration: ~datetime.timedelta + :keyword parameters: List of key value pairs. Required. + :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :keyword selector_id: String that represents a selector. Required. + :paramtype selector_id: str + """ + super().__init__(name=name, **kwargs) + self.type: str = "continuous" + self.duration = duration + self.parameters = parameters + self.selector_id = selector_id + + +class DelayAction(ChaosExperimentAction): + """Model that represents a delay action. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Enum that discriminates between action models. Required. + :vartype type: str + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar duration: ISO8601 formatted string that represents a duration. Required. + :vartype duration: ~datetime.timedelta + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True, "max_length": 2048}, + "duration": {"required": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "duration": {"key": "duration", "type": "duration"}, + } + + def __init__(self, *, name: str, duration: datetime.timedelta, **kwargs: Any) -> None: + """ + :keyword name: String that represents a Capability URN. Required. + :paramtype name: str + :keyword duration: ISO8601 formatted string that represents a duration. Required. + :paramtype duration: ~datetime.timedelta + """ + super().__init__(name=name, **kwargs) + self.type: str = "delay" + self.duration = duration + + +class DiscreteAction(ChaosExperimentAction): + """Model that represents a discrete action. + + All required parameters must be populated in order to send to Azure. + + :ivar type: Enum that discriminates between action models. Required. + :vartype type: str + :ivar name: String that represents a Capability URN. Required. + :vartype name: str + :ivar parameters: List of key value pairs. Required. + :vartype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :ivar selector_id: String that represents a selector. Required. + :vartype selector_id: str + """ + + _validation = { + "type": {"required": True}, + "name": {"required": True, "max_length": 2048}, + "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["_models.KeyValuePair"], selector_id: str, **kwargs: Any) -> None: + """ + :keyword name: String that represents a Capability URN. Required. + :paramtype name: str + :keyword parameters: List of key value pairs. Required. + :paramtype parameters: list[~azure.mgmt.chaos.models.KeyValuePair] + :keyword selector_id: String that represents a selector. Required. + :paramtype selector_id: str + """ + super().__init__(name=name, **kwargs) + self.type: str = "discrete" + self.parameters = parameters + self.selector_id = selector_id + + +class ErrorAdditionalInfo(_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: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_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[~azure.mgmt.chaos.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.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: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_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.). :ivar error: The error object. :vartype error: ~azure.mgmt.chaos.models.ErrorDetail @@ -762,13 +1064,13 @@ class Experiment(TrackedResource): :vartype system_data: ~azure.mgmt.chaos.models.SystemData :ivar identity: The identity of the experiment resource. :vartype identity: ~azure.mgmt.chaos.models.ResourceIdentity + :ivar provisioning_state: Most recent provisioning state for the given experiment resource. + Known values are: "Succeeded", "Failed", "Canceled", "Creating", "Updating", and "Deleting". + :vartype provisioning_state: str or ~azure.mgmt.chaos.models.ProvisioningState :ivar steps: List of steps. Required. - :vartype steps: list[~azure.mgmt.chaos.models.Step] + :vartype steps: list[~azure.mgmt.chaos.models.ChaosExperimentStep] :ivar selectors: List of selectors. Required. - :vartype selectors: list[~azure.mgmt.chaos.models.Selector] - :ivar start_on_creation: A boolean value that indicates if experiment should be started on - creation or not. - :vartype start_on_creation: bool + :vartype selectors: list[~azure.mgmt.chaos.models.ChaosTargetSelector] """ _validation = { @@ -777,7 +1079,8 @@ class Experiment(TrackedResource): "type": {"readonly": True}, "location": {"required": True}, "system_data": {"readonly": True}, - "steps": {"required": True, "min_items": 1}, + "provisioning_state": {"readonly": True}, + "steps": {"required": True, "max_items": 4, "min_items": 1}, "selectors": {"required": True, "min_items": 1}, } @@ -789,20 +1092,19 @@ class Experiment(TrackedResource): "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"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "steps": {"key": "properties.steps", "type": "[ChaosExperimentStep]"}, + "selectors": {"key": "properties.selectors", "type": "[ChaosTargetSelector]"}, } def __init__( self, *, location: str, - steps: List["_models.Step"], - selectors: List["_models.Selector"], + steps: List["_models.ChaosExperimentStep"], + selectors: List["_models.ChaosTargetSelector"], tags: Optional[Dict[str, str]] = None, identity: Optional["_models.ResourceIdentity"] = None, - start_on_creation: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -813,47 +1115,64 @@ def __init__( :keyword identity: The identity of the experiment resource. :paramtype identity: ~azure.mgmt.chaos.models.ResourceIdentity :keyword steps: List of steps. Required. - :paramtype steps: list[~azure.mgmt.chaos.models.Step] + :paramtype steps: list[~azure.mgmt.chaos.models.ChaosExperimentStep] :keyword selectors: List of selectors. Required. - :paramtype selectors: list[~azure.mgmt.chaos.models.Selector] - :keyword start_on_creation: A boolean value that indicates if experiment should be started on - creation or not. - :paramtype start_on_creation: bool + :paramtype selectors: list[~azure.mgmt.chaos.models.ChaosTargetSelector] """ super().__init__(tags=tags, location=location, **kwargs) self.system_data = None self.identity = identity + self.provisioning_state = None self.steps = steps self.selectors = selectors - self.start_on_creation = start_on_creation -class ExperimentCancelOperationResult(_serialization.Model): - """Model that represents the result of a cancel Experiment operation. +class ExperimentExecution(_serialization.Model): + """Model that represents the execution of a Experiment. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: String of the Experiment name. + :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_url: URL to retrieve the Experiment status. - :vartype status_url: str + :ivar status: The status of the execution. + :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime """ _validation = { + "type": {"readonly": True}, + "id": {"readonly": True}, "name": {"readonly": True}, - "status_url": {"readonly": True, "max_length": 2048}, + "status": {"readonly": True}, + "started_at": {"readonly": True}, + "stopped_at": {"readonly": True}, } _attribute_map = { + "type": {"key": "type", "type": "str"}, + "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, - "status_url": {"key": "statusUrl", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "started_at": {"key": "properties.startedAt", "type": "iso-8601"}, + "stopped_at": {"key": "properties.stoppedAt", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) + self.type = None + self.id = None self.name = None - self.status_url = None + self.status = None + self.started_at = None + self.stopped_at = None class ExperimentExecutionActionTargetDetailsError(_serialization.Model): @@ -927,8 +1246,8 @@ def __init__(self, **kwargs: Any) -> None: self.error = None -class ExperimentExecutionDetails(_serialization.Model): # pylint: disable=too-many-instance-attributes - """Model that represents the execution details of a Experiment. +class ExperimentExecutionDetails(_serialization.Model): + """Model that represents the execution details of an Experiment. Variables are only populated by the server, and will be ignored when sending a request. @@ -938,20 +1257,16 @@ class ExperimentExecutionDetails(_serialization.Model): # pylint: disable=too-m :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. + :ivar status: The status of the execution. :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime :ivar failure_reason: The reason why the execution failed. :vartype failure_reason: str - :ivar created_date_time: String that represents the created date time. - :vartype created_date_time: ~datetime.datetime - :ivar last_action_date_time: String that represents the last action date time. - :vartype last_action_date_time: ~datetime.datetime - :ivar start_date_time: String that represents the start date time. - :vartype start_date_time: ~datetime.datetime - :ivar stop_date_time: String that represents the stop date time. - :vartype stop_date_time: ~datetime.datetime + :ivar last_action_at: String that represents the last action date time. + :vartype last_action_at: ~datetime.datetime :ivar run_information: The information of the experiment run. :vartype run_information: ~azure.mgmt.chaos.models.ExperimentExecutionDetailsPropertiesRunInformation @@ -961,13 +1276,11 @@ class ExperimentExecutionDetails(_serialization.Model): # pylint: disable=too-m "type": {"readonly": True}, "id": {"readonly": True}, "name": {"readonly": True}, - "experiment_id": {"readonly": True}, "status": {"readonly": True}, + "started_at": {"readonly": True}, + "stopped_at": {"readonly": True}, "failure_reason": {"readonly": True}, - "created_date_time": {"readonly": True}, - "last_action_date_time": {"readonly": True}, - "start_date_time": {"readonly": True}, - "stop_date_time": {"readonly": True}, + "last_action_at": {"readonly": True}, "run_information": {"readonly": True}, } @@ -975,13 +1288,11 @@ class ExperimentExecutionDetails(_serialization.Model): # pylint: disable=too-m "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"}, + "started_at": {"key": "properties.startedAt", "type": "iso-8601"}, + "stopped_at": {"key": "properties.stoppedAt", "type": "iso-8601"}, "failure_reason": {"key": "properties.failureReason", "type": "str"}, - "created_date_time": {"key": "properties.createdDateTime", "type": "iso-8601"}, - "last_action_date_time": {"key": "properties.lastActionDateTime", "type": "iso-8601"}, - "start_date_time": {"key": "properties.startDateTime", "type": "iso-8601"}, - "stop_date_time": {"key": "properties.stopDateTime", "type": "iso-8601"}, + "last_action_at": {"key": "properties.lastActionAt", "type": "iso-8601"}, "run_information": { "key": "properties.runInformation", "type": "ExperimentExecutionDetailsPropertiesRunInformation", @@ -994,179 +1305,152 @@ def __init__(self, **kwargs: Any) -> None: self.type = None self.id = None self.name = None - self.experiment_id = None self.status = None + self.started_at = None + self.stopped_at = None self.failure_reason = None - self.created_date_time = None - self.last_action_date_time = None - self.start_date_time = None - self.stop_date_time = None + self.last_action_at = None self.run_information = None -class ExperimentExecutionDetailsListResult(_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[~azure.mgmt.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}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[ExperimentExecutionDetails]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value = None - self.next_link = None - - -class ExperimentExecutionDetailsPropertiesRunInformation(_serialization.Model): - """The information of the experiment run. +class ExperimentExecutionProperties(_serialization.Model): + """Model that represents the execution properties of an Experiment. 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[~azure.mgmt.chaos.models.StepStatus] + :ivar status: The status of the execution. + :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime """ _validation = { - "steps": {"readonly": True}, + "status": {"readonly": True}, + "started_at": {"readonly": True}, + "stopped_at": {"readonly": True}, } _attribute_map = { - "steps": {"key": "steps", "type": "[StepStatus]"}, + "status": {"key": "status", "type": "str"}, + "started_at": {"key": "startedAt", "type": "iso-8601"}, + "stopped_at": {"key": "stoppedAt", "type": "iso-8601"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.steps = None + self.status = None + self.started_at = None + self.stopped_at = None -class ExperimentListResult(_serialization.Model): - """Model that represents a list of Experiment resources and a link for pagination. +class ExperimentExecutionDetailsProperties(ExperimentExecutionProperties): + """Model that represents the extended properties of an experiment execution. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of Experiment resources. - :vartype value: list[~azure.mgmt.chaos.models.Experiment] - :ivar next_link: URL to retrieve the next page of Experiment resources. - :vartype next_link: str + :ivar status: The status of the execution. + :vartype status: str + :ivar started_at: String that represents the start date time. + :vartype started_at: ~datetime.datetime + :ivar stopped_at: String that represents the stop date time. + :vartype stopped_at: ~datetime.datetime + :ivar failure_reason: The reason why the execution failed. + :vartype failure_reason: str + :ivar last_action_at: String that represents the last action date time. + :vartype last_action_at: ~datetime.datetime + :ivar run_information: The information of the experiment run. + :vartype run_information: + ~azure.mgmt.chaos.models.ExperimentExecutionDetailsPropertiesRunInformation """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True, "max_length": 2048}, + "status": {"readonly": True}, + "started_at": {"readonly": True}, + "stopped_at": {"readonly": True}, + "failure_reason": {"readonly": True}, + "last_action_at": {"readonly": True}, + "run_information": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Experiment]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "started_at": {"key": "startedAt", "type": "iso-8601"}, + "stopped_at": {"key": "stoppedAt", "type": "iso-8601"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "last_action_at": {"key": "lastActionAt", "type": "iso-8601"}, + "run_information": {"key": "runInformation", "type": "ExperimentExecutionDetailsPropertiesRunInformation"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.failure_reason = None + self.last_action_at = None + self.run_information = None -class ExperimentStartOperationResult(_serialization.Model): - """Model that represents the result of a start Experiment operation. +class ExperimentExecutionDetailsPropertiesRunInformation(_serialization.Model): + """The information of the experiment run. 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 + :ivar steps: The steps of the experiment run. + :vartype steps: list[~azure.mgmt.chaos.models.StepStatus] """ _validation = { - "name": {"readonly": True}, - "status_url": {"readonly": True, "max_length": 2048}, + "steps": {"readonly": True}, } _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status_url": {"key": "statusUrl", "type": "str"}, + "steps": {"key": "steps", "type": "[StepStatus]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.name = None - self.status_url = None + self.steps = None -class ExperimentStatus(_serialization.Model): - """Model that represents the status of a Experiment. +class ExperimentExecutionListResult(_serialization.Model): + """Model that represents a list of Experiment executions and a link for pagination. 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 + :ivar value: List of Experiment executions. + :vartype value: list[~azure.mgmt.chaos.models.ExperimentExecution] + :ivar next_link: URL to retrieve the next page of Experiment executions. + :vartype next_link: str """ _validation = { - "type": {"readonly": True}, - "id": {"readonly": True}, - "name": {"readonly": True}, - "status": {"readonly": True}, - "created_date_utc": {"readonly": True}, - "end_date_utc": {"readonly": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True, "max_length": 2048}, } _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"}, + "value": {"key": "value", "type": "[ExperimentExecution]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.id = None - self.name = None - self.status = None - self.created_date_utc = None - self.end_date_utc = None + self.value = None + self.next_link = None -class ExperimentStatusListResult(_serialization.Model): - """Model that represents a list of Experiment statuses and a link for pagination. +class ExperimentListResult(_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 statuses. - :vartype value: list[~azure.mgmt.chaos.models.ExperimentStatus] - :ivar next_link: URL to retrieve the next page of Experiment statuses. + :ivar value: List of Experiment resources. + :vartype value: list[~azure.mgmt.chaos.models.Experiment] + :ivar next_link: URL to retrieve the next page of Experiment resources. :vartype next_link: str """ @@ -1176,7 +1460,7 @@ class ExperimentStatusListResult(_serialization.Model): } _attribute_map = { - "value": {"key": "value", "type": "[ExperimentStatus]"}, + "value": {"key": "value", "type": "[Experiment]"}, "next_link": {"key": "nextLink", "type": "str"}, } @@ -1187,53 +1471,24 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ExperimentUpdate(_serialization.Model): - """Describes an experiment update. - - :ivar identity: The identity of the experiment resource. - :vartype identity: ~azure.mgmt.chaos.models.ResourceIdentity - """ - - _attribute_map = { - "identity": {"key": "identity", "type": "ResourceIdentity"}, - } - - def __init__(self, *, identity: Optional["_models.ResourceIdentity"] = None, **kwargs: Any) -> None: - """ - :keyword identity: The identity of the experiment resource. - :paramtype identity: ~azure.mgmt.chaos.models.ResourceIdentity - """ - super().__init__(**kwargs) - self.identity = identity - - -class Filter(_serialization.Model): - """Model that represents available filter types that can be applied to a targets list. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - SimpleFilter - - All required parameters must be populated in order to send to Azure. +class ExperimentUpdate(_serialization.Model): + """Describes an experiment update. - :ivar type: Enum that discriminates between filter types. Currently only ``Simple`` type is - supported. Required. "Simple" - :vartype type: str or ~azure.mgmt.chaos.models.FilterType + :ivar identity: The identity of the experiment resource. + :vartype identity: ~azure.mgmt.chaos.models.ResourceIdentity """ - _validation = { - "type": {"required": True}, - } - _attribute_map = { - "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "ResourceIdentity"}, } - _subtype_map = {"type": {"Simple": "SimpleFilter"}} - - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__(self, *, identity: Optional["_models.ResourceIdentity"] = None, **kwargs: Any) -> None: + """ + :keyword identity: The identity of the experiment resource. + :paramtype identity: ~azure.mgmt.chaos.models.ResourceIdentity + """ super().__init__(**kwargs) - self.type: Optional[str] = None + self.identity = identity class KeyValuePair(_serialization.Model): @@ -1269,124 +1524,6 @@ def __init__(self, *, key: str, value: str, **kwargs: Any) -> None: self.value = value -class Selector(_serialization.Model): - """Model that represents a selector in the Experiment resource. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ListSelector, QuerySelector - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar id: String of the selector ID. Required. - :vartype id: str - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.Filter - """ - - _validation = { - "type": {"required": True}, - "id": {"required": True, "min_length": 1}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "filter": {"key": "filter", "type": "Filter"}, - } - - _subtype_map = {"type": {"List": "ListSelector", "Query": "QuerySelector"}} - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - additional_properties: Optional[Dict[str, Any]] = None, - filter: Optional["_models.Filter"] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword id: String of the selector ID. Required. - :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.Filter - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.type: Optional[str] = None - self.id = id - self.filter = filter - - -class ListSelector(Selector): - """Model that represents a list selector. - - All required parameters must be populated in order to send to Azure. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar id: String of the selector ID. Required. - :vartype id: str - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.Filter - :ivar targets: List of Target references. Required. - :vartype targets: list[~azure.mgmt.chaos.models.TargetReference] - """ - - _validation = { - "type": {"required": True}, - "id": {"required": True, "min_length": 1}, - "targets": {"required": True, "min_items": 1}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, - "id": {"key": "id", "type": "str"}, - "filter": {"key": "filter", "type": "Filter"}, - "targets": {"key": "targets", "type": "[TargetReference]"}, - } - - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - targets: List["_models.TargetReference"], - additional_properties: Optional[Dict[str, Any]] = None, - filter: Optional["_models.Filter"] = None, # pylint: disable=redefined-builtin - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword id: String of the selector ID. Required. - :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.Filter - :keyword targets: List of Target references. Required. - :paramtype targets: list[~azure.mgmt.chaos.models.TargetReference] - """ - super().__init__(additional_properties=additional_properties, id=id, filter=filter, **kwargs) - self.type: str = "List" - self.targets = targets - - class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. @@ -1508,73 +1645,64 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class QuerySelector(Selector): - """Model that represents a query selector. - - All required parameters must be populated in order to send to Azure. +class OperationStatus(_serialization.Model): + """The status of operation. - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar type: Enum of the selector type. Required. Known values are: "List" and "Query". - :vartype type: str or ~azure.mgmt.chaos.models.SelectorType - :ivar id: String of the selector ID. Required. + :ivar id: The operation Id. :vartype id: str - :ivar filter: Model that represents available filter types that can be applied to a targets - list. - :vartype filter: ~azure.mgmt.chaos.models.Filter - :ivar query_string: Azure Resource Graph (ARG) Query Language query for target resources. - Required. - :vartype query_string: str - :ivar subscription_ids: Subscription id list to scope resource query. Required. - :vartype subscription_ids: list[str] + :ivar name: The operation name. + :vartype name: str + :ivar start_time: The start time of the operation. + :vartype start_time: str + :ivar end_time: The end time of the operation. + :vartype end_time: str + :ivar status: The status of the operation. + :vartype status: str + :ivar error: The error detail of the operation if any. + :vartype error: ~azure.mgmt.chaos.models.ErrorResponse """ - _validation = { - "type": {"required": True}, - "id": {"required": True, "min_length": 1}, - "query_string": {"required": True}, - "subscription_ids": {"required": True, "min_items": 1}, - } - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "type": {"key": "type", "type": "str"}, "id": {"key": "id", "type": "str"}, - "filter": {"key": "filter", "type": "Filter"}, - "query_string": {"key": "queryString", "type": "str"}, - "subscription_ids": {"key": "subscriptionIds", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorResponse"}, } def __init__( self, *, - id: str, # pylint: disable=redefined-builtin - query_string: str, - subscription_ids: List[str], - additional_properties: Optional[Dict[str, Any]] = None, - filter: Optional["_models.Filter"] = None, # pylint: disable=redefined-builtin + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, + status: Optional[str] = None, + error: Optional["_models.ErrorResponse"] = None, **kwargs: Any ) -> None: """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword id: String of the selector ID. Required. + :keyword id: The operation Id. :paramtype id: str - :keyword filter: Model that represents available filter types that can be applied to a targets - list. - :paramtype filter: ~azure.mgmt.chaos.models.Filter - :keyword query_string: Azure Resource Graph (ARG) Query Language query for target resources. - Required. - :paramtype query_string: str - :keyword subscription_ids: Subscription id list to scope resource query. Required. - :paramtype subscription_ids: list[str] + :keyword name: The operation name. + :paramtype name: str + :keyword start_time: The start time of the operation. + :paramtype start_time: str + :keyword end_time: The end time of the operation. + :paramtype end_time: str + :keyword status: The status of the operation. + :paramtype status: str + :keyword error: The error detail of the operation if any. + :paramtype error: ~azure.mgmt.chaos.models.ErrorResponse """ - super().__init__(additional_properties=additional_properties, id=id, filter=filter, **kwargs) - self.type: str = "Query" - self.query_string = query_string - self.subscription_ids = subscription_ids + super().__init__(**kwargs) + self.id = id + self.name = name + self.start_time = start_time + self.end_time = end_time + self.status = status + self.error = error class ResourceIdentity(_serialization.Model): @@ -1639,90 +1767,6 @@ def __init__( self.tenant_id = None -class SimpleFilter(Filter): - """Model that represents a simple target filter. - - All required parameters must be populated in order to send to Azure. - - :ivar type: Enum that discriminates between filter types. Currently only ``Simple`` type is - supported. Required. "Simple" - :vartype type: str or ~azure.mgmt.chaos.models.FilterType - :ivar parameters: Model that represents the Simple filter parameters. - :vartype parameters: ~azure.mgmt.chaos.models.SimpleFilterParameters - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "parameters": {"key": "parameters", "type": "SimpleFilterParameters"}, - } - - def __init__(self, *, parameters: Optional["_models.SimpleFilterParameters"] = None, **kwargs: Any) -> None: - """ - :keyword parameters: Model that represents the Simple filter parameters. - :paramtype parameters: ~azure.mgmt.chaos.models.SimpleFilterParameters - """ - super().__init__(**kwargs) - self.type: str = "Simple" - self.parameters = parameters - - -class SimpleFilterParameters(_serialization.Model): - """Model that represents the Simple filter parameters. - - :ivar zones: List of Azure availability zones to filter targets by. - :vartype zones: list[str] - """ - - _attribute_map = { - "zones": {"key": "zones", "type": "[str]"}, - } - - def __init__(self, *, zones: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword zones: List of Azure availability zones to filter targets by. - :paramtype zones: list[str] - """ - super().__init__(**kwargs) - self.zones = zones - - -class Step(_serialization.Model): - """Model that represents a step in the Experiment resource. - - All required parameters must be populated in order to send to Azure. - - :ivar name: String of the step name. Required. - :vartype name: str - :ivar branches: List of branches. Required. - :vartype branches: list[~azure.mgmt.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["_models.Branch"], **kwargs: Any) -> None: - """ - :keyword name: String of the step name. Required. - :paramtype name: str - :keyword branches: List of branches. Required. - :paramtype branches: list[~azure.mgmt.chaos.models.Branch] - """ - super().__init__(**kwargs) - self.name = name - self.branches = branches - - class StepStatus(_serialization.Model): """Model that represents the a list of branches and branch statuses. 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 index bae252b95e54..531fb369a6b5 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/__init__.py @@ -9,6 +9,7 @@ from ._capabilities_operations import CapabilitiesOperations from ._capability_types_operations import CapabilityTypesOperations from ._experiments_operations import ExperimentsOperations +from ._operation_statuses_operations import OperationStatusesOperations from ._operations import Operations from ._target_types_operations import TargetTypesOperations from ._targets_operations import TargetsOperations @@ -21,6 +22,7 @@ "CapabilitiesOperations", "CapabilityTypesOperations", "ExperimentsOperations", + "OperationStatusesOperations", "Operations", "TargetTypesOperations", "TargetsOperations", 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 index 4e8882ed02c5..eda8889ca821 100644 --- 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 @@ -28,7 +28,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +51,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +81,7 @@ def build_list_request( "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,7 +109,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -142,7 +142,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -166,7 +166,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -199,7 +199,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -223,7 +223,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -257,7 +257,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") 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 index 54d1bae29f33..59af266d98f0 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +47,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +66,7 @@ def build_list_request( "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +87,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +109,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") 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 index 84a677e74107..2ff04ecb0fd9 100644 --- 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 @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -21,14 +21,16 @@ from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +49,7 @@ def build_list_all_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +63,7 @@ def build_list_all_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,7 +91,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +111,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +134,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +157,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +174,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -195,7 +197,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -212,7 +214,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -236,7 +238,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -255,7 +257,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -279,7 +281,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -298,7 +300,7 @@ def build_cancel_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -321,7 +323,7 @@ def build_cancel_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -338,7 +340,7 @@ def build_start_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -361,7 +363,7 @@ def build_start_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -372,19 +374,19 @@ def build_start_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_all_statuses_request( +def build_list_all_executions_request( resource_group_name: str, experiment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url( @@ -401,7 +403,7 @@ def build_list_all_statuses_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -412,19 +414,19 @@ def build_list_all_statuses_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_status_request( - resource_group_name: str, experiment_name: str, status_id: str, subscription_id: str, **kwargs: Any +def build_get_execution_request( + resource_group_name: str, experiment_name: str, execution_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses/{statusId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url( @@ -439,15 +441,15 @@ def build_get_status_request( "experimentName": _SERIALIZER.url( "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" ), - "statusId": _SERIALIZER.url( - "status_id", - status_id, + "executionId": _SERIALIZER.url( + "execution_id", + execution_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: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -458,59 +460,19 @@ def build_get_status_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_execution_details_request( - resource_group_name: str, experiment_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails", - ) # pylint: disable=line-too-long - path_format_arguments = { - "subscriptionId": _SERIALIZER.url( - "subscription_id", - 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": _SERIALIZER.url( - "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" - ), - "experimentName": _SERIALIZER.url( - "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" - ), - } - - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_get_execution_details_request( - resource_group_name: str, experiment_name: str, execution_details_id: str, subscription_id: str, **kwargs: Any +def build_execution_details_request( + resource_group_name: str, experiment_name: str, execution_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails", ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url( @@ -525,15 +487,15 @@ def build_get_execution_details_request( "experimentName": _SERIALIZER.url( "experiment_name", experiment_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" ), - "executionDetailsId": _SERIALIZER.url( - "execution_details_id", - execution_details_id, + "executionId": _SERIALIZER.url( + "execution_id", + execution_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: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -541,7 +503,7 @@ def build_get_execution_details_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) class ExperimentsOperations: @@ -756,21 +718,9 @@ def get_next(next_link=None): "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments" } - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements + def _delete_initial( # pylint: disable=inconsistent-return-statements 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. Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :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: - """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -790,7 +740,7 @@ def delete( # pylint: disable=inconsistent-return-statements experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -804,7 +754,7 @@ def delete( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response - if response.status_code not in [200, 204]: + 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, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -812,7 +762,72 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = { + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + @distributed_trace + def begin_delete(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete a Experiment resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param experiment_name: String that represents a Experiment resource name. Required. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } @@ -878,8 +893,76 @@ def get(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } + def _create_or_update_initial( + self, resource_group_name: str, experiment_name: str, experiment: Union[_models.Experiment, IO], **kwargs: Any + ) -> _models.Experiment: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(experiment, (IOBase, bytes)): + _content = experiment + else: + _json = self._serialize.body(experiment, "Experiment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("Experiment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("Experiment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -887,7 +970,7 @@ def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -900,13 +983,20 @@ def create_or_update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -914,7 +1004,7 @@ def create_or_update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -927,15 +1017,22 @@ def create_or_update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, experiment_name: str, experiment: Union[_models.Experiment, IO], **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """Create or update a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -949,10 +1046,74 @@ def create_or_update( Default value is None. :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + experiment=experiment, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Experiment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + def _update_initial( + self, + resource_group_name: str, + experiment_name: str, + experiment: Union[_models.ExperimentUpdate, IO], + **kwargs: Any + ) -> _models.Experiment: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -974,9 +1135,9 @@ def create_or_update( if isinstance(experiment, (IOBase, bytes)): _content = experiment else: - _json = self._serialize.body(experiment, "Experiment") + _json = self._serialize.body(experiment, "ExperimentUpdate") - request = build_create_or_update_request( + request = build_update_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, @@ -984,7 +1145,7 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) @@ -998,7 +1159,7 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1010,12 +1171,12 @@ def create_or_update( return deserialized - create_or_update.metadata = { + _update_initial.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" } @overload - def update( + def begin_update( self, resource_group_name: str, experiment_name: str, @@ -1023,7 +1184,7 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -1036,13 +1197,20 @@ def update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( + def begin_update( self, resource_group_name: str, experiment_name: str, @@ -1050,7 +1218,7 @@ def update( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -1063,19 +1231,26 @@ def update( Default value is "application/json". :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( + def begin_update( self, resource_group_name: str, experiment_name: str, experiment: Union[_models.ExperimentUpdate, IO], **kwargs: Any - ) -> _models.Experiment: + ) -> LROPoller[_models.Experiment]: """The operation to update an experiment. :param resource_group_name: String that represents an Azure resource group. Required. @@ -1089,10 +1264,70 @@ def update( Default value is None. :paramtype content_type: 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: ~azure.mgmt.chaos.models.Experiment + :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[~azure.mgmt.chaos.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + experiment_name=experiment_name, + experiment=experiment, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Experiment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + + def _cancel_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1101,30 +1336,18 @@ def update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(experiment, (IOBase, bytes)): - _content = experiment - else: - _json = self._serialize.body(experiment, "ExperimentUpdate") + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_update_request( + request = build_cancel_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.update.metadata["url"], + template_url=self._cancel_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1138,26 +1361,20 @@ def update( response = pipeline_response.http_response - if response.status_code not in [200]: + 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, pipeline_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 + return cls(pipeline_response, None, {}) - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + _cancel_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" } @distributed_trace - def cancel( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> _models.ExperimentCancelOperationResult: + def begin_cancel(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: """Cancel a running Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -1165,10 +1382,65 @@ def cancel( :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExperimentCancelOperationResult or the result of cls(response) - :rtype: ~azure.mgmt.chaos.models.ExperimentCancelOperationResult + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._cancel_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_cancel.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + } + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, experiment_name: str, **kwargs: Any + ) -> None: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1181,14 +1453,14 @@ def cancel( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentCancelOperationResult] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - request = build_cancel_request( + request = build_start_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel.metadata["url"], + template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1207,21 +1479,15 @@ def cancel( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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 + return cls(pipeline_response, None, {}) - cancel.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/cancel" + _start_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" } @distributed_trace - def start( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> _models.ExperimentStartOperationResult: + def begin_start(self, resource_group_name: str, experiment_name: str, **kwargs: Any) -> LROPoller[None]: """Start a Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. @@ -1229,79 +1495,82 @@ def start( :param experiment_name: String that represents a Experiment resource name. Required. :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: ~azure.mgmt.chaos.models.ExperimentStartOperationResult + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStartOperationResult] = kwargs.pop("cls", None) - - request = build_start_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.start.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **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, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("ExperimentStartOperationResult", pipeline_response) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._start_initial( # type: ignore + resource_group_name=resource_group_name, + experiment_name=experiment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - if cls: - return cls(pipeline_response, deserialized, {}) + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) - return deserialized + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, 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, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - start.metadata = { + begin_start.metadata = { "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/start" } @distributed_trace - def list_all_statuses( + def list_all_executions( self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> Iterable["_models.ExperimentStatus"]: - """Get a list of statuses of a Experiment resource. + ) -> Iterable["_models.ExperimentExecution"]: + """Get a list of executions of an Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :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 ExperimentStatus or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ExperimentStatus] + :return: An iterator like instance of either ExperimentExecution or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ExperimentExecution] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStatusListResult] = kwargs.pop("cls", None) + cls: ClsType[_models.ExperimentExecutionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1314,12 +1583,12 @@ def list_all_statuses( def prepare_request(next_link=None): if not next_link: - request = build_list_all_statuses_request( + request = build_list_all_executions_request( resource_group_name=resource_group_name, experiment_name=experiment_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_all_statuses.metadata["url"], + template_url=self.list_all_executions.metadata["url"], headers=_headers, params=_params, ) @@ -1345,7 +1614,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentStatusListResult", pipeline_response) + deserialized = self._deserialize("ExperimentExecutionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore @@ -1369,25 +1638,25 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_all_statuses.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/statuses" + list_all_executions.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions" } @distributed_trace - 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. + def get_execution( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any + ) -> _models.ExperimentExecution: + """Get an execution of an Experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str - :param status_id: GUID that represents a Experiment status. Required. - :type status_id: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_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: ~azure.mgmt.chaos.models.ExperimentStatus + :return: ExperimentExecution or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.ExperimentExecution :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { @@ -1402,15 +1671,15 @@ def get_status( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentStatus] = kwargs.pop("cls", None) + cls: ClsType[_models.ExperimentExecution] = kwargs.pop("cls", None) - request = build_get_status_request( + request = build_get_execution_request( resource_group_name=resource_group_name, experiment_name=experiment_name, - status_id=status_id, + execution_id=execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_status.metadata["url"], + template_url=self.get_execution.metadata["url"], headers=_headers, params=_params, ) @@ -1429,121 +1698,29 @@ def get_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ExperimentStatus", pipeline_response) + deserialized = self._deserialize("ExperimentExecution", 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}" - } - - @distributed_trace - def list_execution_details( - self, resource_group_name: str, experiment_name: str, **kwargs: Any - ) -> Iterable["_models.ExperimentExecutionDetails"]: - """Get a list of execution details of a Experiment resource. - - :param resource_group_name: String that represents an Azure resource group. Required. - :type resource_group_name: str - :param experiment_name: String that represents a Experiment resource name. Required. - :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 ExperimentExecutionDetails or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.ExperimentExecutionDetails] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.ExperimentExecutionDetailsListResult] = kwargs.pop("cls", None) - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_execution_details_request( - resource_group_name=resource_group_name, - experiment_name=experiment_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_execution_details.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ExperimentExecutionDetailsListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_execution_details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails" + get_execution.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}" } @distributed_trace - def get_execution_details( - self, resource_group_name: str, experiment_name: str, execution_details_id: str, **kwargs: Any + def execution_details( + self, resource_group_name: str, experiment_name: str, execution_id: str, **kwargs: Any ) -> _models.ExperimentExecutionDetails: - """Get an execution detail of a Experiment resource. + """Execution details of an experiment resource. :param resource_group_name: String that represents an Azure resource group. Required. :type resource_group_name: str :param experiment_name: String that represents a Experiment resource name. Required. :type experiment_name: str - :param execution_details_id: GUID that represents a Experiment execution detail. Required. - :type execution_details_id: str + :param execution_id: GUID that represents a Experiment execution detail. Required. + :type execution_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: ~azure.mgmt.chaos.models.ExperimentExecutionDetails @@ -1563,13 +1740,13 @@ def get_execution_details( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ExperimentExecutionDetails] = kwargs.pop("cls", None) - request = build_get_execution_details_request( + request = build_execution_details_request( resource_group_name=resource_group_name, experiment_name=experiment_name, - execution_details_id=execution_details_id, + execution_id=execution_id, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_execution_details.metadata["url"], + template_url=self.execution_details.metadata["url"], headers=_headers, params=_params, ) @@ -1595,6 +1772,6 @@ def get_execution_details( return deserialized - get_execution_details.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executionDetails/{executionDetailsId}" + execution_details.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}/executions/{executionId}/getExecutionDetails" } diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py new file mode 100644 index 000000000000..2d0bece80471 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operation_statuses_operations.py @@ -0,0 +1,150 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request(location: str, async_operation_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationsStatuses/{asyncOperationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, "str"), + "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, "str"), + "subscriptionId": _SERIALIZER.url( + "subscription_id", + 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: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class OperationStatusesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`operation_statuses` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, async_operation_id: str, **kwargs: Any) -> _models.OperationStatus: + """Get the status of a long running azure asynchronous operation. + + :param location: The region name of operation. Required. + :type location: str + :param async_operation_id: The operation Id. Required. + :type async_operation_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OperationStatus or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.OperationStatus + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) + + request = build_get_request( + location=location, + async_operation_id=async_operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/locations/{location}/operationsStatuses/{asyncOperationId}" + } 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 index e0239ed80506..05a3d35a4a87 100644 --- a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_operations.py @@ -40,7 +40,7 @@ def build_list_all_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL 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 index 68f1f863ecc6..fcfa1e3c6f8e 100644 --- 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 @@ -27,7 +27,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +42,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +59,7 @@ def build_list_request( "locationName": _SERIALIZER.url("location_name", location_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +78,7 @@ def build_get_request(location_name: str, target_type_name: str, subscription_id _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request(location_name: str, target_type_name: str, subscription_id "targetTypeName": _SERIALIZER.url("target_type_name", target_type_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") 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 index 6be45444c932..c5fc18c6aa81 100644 --- 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 @@ -28,7 +28,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +50,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +79,7 @@ def build_list_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,7 +106,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +136,7 @@ def build_get_request( "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,7 +159,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +189,7 @@ def build_delete_request( "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -212,7 +212,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-04-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-11-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -243,7 +243,7 @@ def build_create_or_update_request( "targetName": _SERIALIZER.url("target_name", target_name, "str", pattern=r"^[a-zA-Z0-9_\-\.]+$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/start_aexperiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_experiment.py similarity index 89% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/start_aexperiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_experiment.py index 7380abd953af..ba2c7e7fc3a2 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/start_aexperiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python start_aexperiment.py + python cancel_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,13 +29,12 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.start( + client.experiments.begin_cancel( resource_group_name="exampleRG", experiment_name="exampleExperiment", - ) - print(response) + ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/StartAExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/CancelExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_acapability.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_capability.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_acapability.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_capability.py index e3f9d8546889..5189fb59a9f8 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_acapability.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_capability.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python create_or_update_acapability.py + python create_update_capability.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -41,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/CreateOrUpdateACapability.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/CreateUpdateCapability.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aexperiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_experiment.py similarity index 94% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aexperiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_experiment.py index 8814a73aaabd..f72a2abb65df 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aexperiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python create_or_update_aexperiment.py + python create_update_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,7 +29,7 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.create_or_update( + response = client.experiments.begin_create_or_update( resource_group_name="exampleRG", experiment_name="exampleExperiment", experiment={ @@ -69,10 +69,10 @@ def main(): ], }, }, - ) + ).result() print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/CreateOrUpdateAExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/CreateUpdateExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_atarget.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_target.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_atarget.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_target.py index e6b6b856a418..360cc5ad62b4 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_atarget.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_update_target.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python create_or_update_atarget.py + python create_update_target.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/CreateOrUpdateATarget.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/CreateUpdateTarget.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_acapability.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_capability.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/delete_acapability.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/delete_capability.py index 38454829c884..4e21a357fe1a 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_acapability.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_capability.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python delete_acapability.py + python delete_capability.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -39,6 +39,6 @@ def main(): ) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/DeleteACapability.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/DeleteCapability.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_aexperiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_experiment.py similarity index 89% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_aexperiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/delete_experiment.py index 1a24840da0e3..b9558dbe79c8 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/cancel_aexperiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python cancel_aexperiment.py + python delete_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,13 +29,12 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.cancel( + client.experiments.begin_delete( resource_group_name="exampleRG", experiment_name="exampleExperiment", - ) - print(response) + ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/CancelAExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/DeleteExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_atarget.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_target.py similarity index 94% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/delete_atarget.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/delete_target.py index 078108093891..648065badd55 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_atarget.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_target.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python delete_atarget.py + python delete_target.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -38,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/DeleteATarget.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/DeleteTarget.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_status.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/details_experiment.py similarity index 86% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_status.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/details_experiment.py index f91455706470..0058f1b6d740 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_status.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/details_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_aexperiment_status.py + python details_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,14 +29,14 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.get_status( + response = client.experiments.execution_details( resource_group_name="exampleRG", experiment_name="exampleExperiment", - status_id="50734542-2e64-4e08-814c-cc0e7475f7e4", + execution_id="f24500ad-744e-4a26-864b-b76199eac333", ) print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetAExperimentStatus.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/DetailsExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_execution_details.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_execution_details.py deleted file mode 100644 index 01f59c47e05c..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_execution_details.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.chaos import ChaosManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-chaos -# USAGE - python get_aexperiment_execution_details.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = ChaosManagementClient( - credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", - ) - - response = client.experiments.get_execution_details( - resource_group_name="exampleRG", - experiment_name="exampleExperiment", - execution_details_id="f24500ad-744e-4a26-864b-b76199eac333", - ) - print(response) - - -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetAExperimentExecutionDetails.json -if __name__ == "__main__": - main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability.py similarity index 94% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability.py index 67524b44cf20..70eb096539f3 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_acapability.py + python get_capability.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -40,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetACapability.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetCapability.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability_type.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability_type.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability_type.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability_type.py index 44d279f8b9b5..852b259b9f0c 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_acapability_type.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_capability_type.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_acapability_type.py + python get_capability_type.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetACapabilityType.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetCapabilityType.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment.py index 9bde49e494b8..8b0f69376dc1 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_aexperiment.py + python get_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetAExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution.py new file mode 100644 index 000000000000..91bb4954bde3 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution.py @@ -0,0 +1,42 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python get_experiment_execution.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.experiments.get_execution( + resource_group_name="exampleRG", + experiment_name="exampleExperiment", + execution_id="f24500ad-744e-4a26-864b-b76199eac333", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetExperimentExecution.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_operation_status.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_operation_status.py new file mode 100644 index 000000000000..c4fbb73ed034 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_operation_status.py @@ -0,0 +1,41 @@ +# 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.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python get_operation_status.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="613192d7-503f-477a-9cfe-4efc3ee2bd60", + ) + + response = client.operation_statuses.get( + location="West US", + async_operation_id="713192d7-503f-477a-9cfe-4efc3ee2bd11", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetOperationStatus.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_target.py similarity index 94% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_target.py index 0ebd6adc92a9..2e408203f0b8 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_target.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_atarget.py + python get_target.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetATarget.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetTarget.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget_type.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_target_type.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget_type.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_target_type.py index 60f88b7330dc..c7c08dda192f 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_atarget_type.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_target_type.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_atarget_type.py + python get_target_type.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetATargetType.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetTargetType.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capabilities.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capabilities.py index 7ec0b454ef0f..5e58b39a61ba 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capabilities.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capabilities.py @@ -40,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListCapabilities.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListCapabilities.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capability_types.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capability_types.py index 95d924ba272e..87e29b50bf59 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capability_types.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_capability_types.py @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListCapabilityTypes.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListCapabilityTypes.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_statuses.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions.py similarity index 89% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_statuses.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions.py index 3d782caa0b17..67229ccb8d22 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_statuses.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python list_experiment_statuses.py + python list_experiment_executions.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,7 +29,7 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.list_all_statuses( + response = client.experiments.list_all_executions( resource_group_name="exampleRG", experiment_name="exampleExperiment", ) @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListExperimentStatuses.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListExperimentExecutions.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions_details.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions_details.py deleted file mode 100644 index 942fe7a83d46..000000000000 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions_details.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.chaos import ChaosManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-chaos -# USAGE - python list_experiment_executions_details.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = ChaosManagementClient( - credential=DefaultAzureCredential(), - subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", - ) - - response = client.experiments.list_execution_details( - resource_group_name="exampleRG", - experiment_name="exampleExperiment", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListExperimentExecutionsDetails.json -if __name__ == "__main__": - main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_aresource_group.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_aresource_group.py index 01f301697ff8..e620e8abc284 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_aresource_group.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_aresource_group.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListExperimentsInAResourceGroup.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListExperimentsInAResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_asubscription.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_asubscription.py index 7b8b0ccf5b02..3b68c2a5accd 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_asubscription.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiments_in_asubscription.py @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListExperimentsInASubscription.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListExperimentsInASubscription.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_target_types.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_target_types.py index 0796e573d4f1..455c44cf5096 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_target_types.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_target_types.py @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListTargetTypes.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListTargetTypes.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_targets.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_targets.py index 0d604b702ba5..c0060c971866 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_targets.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_targets.py @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListTargets.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListTargets.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aexperiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/start_experiment.py similarity index 90% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aexperiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/start_experiment.py index 16598c6b659c..92bca052c02d 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aexperiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/start_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python delete_aexperiment.py + python start_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,12 +29,12 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - client.experiments.delete( + client.experiments.begin_start( resource_group_name="exampleRG", experiment_name="exampleExperiment", - ) + ).result() -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/DeleteAExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/StartExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/patch_experiment.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/update_experiment.py similarity index 91% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/patch_experiment.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/update_experiment.py index 92cd5013b40a..9340f9ebbbd0 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/patch_experiment.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/update_experiment.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python patch_experiment.py + python update_experiment.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -29,7 +29,7 @@ def main(): subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", ) - response = client.experiments.update( + response = client.experiments.begin_update( resource_group_name="exampleRG", experiment_name="exampleExperiment", experiment={ @@ -40,10 +40,10 @@ def main(): }, } }, - ) + ).result() print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/PatchExperiment.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/UpdateExperiment.json if __name__ == "__main__": main()