diff --git a/sdk/chaos/azure-mgmt-chaos/_meta.json b/sdk/chaos/azure-mgmt-chaos/_meta.json index 079f23a029db..a635cf93615b 100644 --- a/sdk/chaos/azure-mgmt-chaos/_meta.json +++ b/sdk/chaos/azure-mgmt-chaos/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e680f9bf4f154ec427ba7feac432ed8efd9665d0", + "commit": "94c758cfd70dffe4d3248b25d1cc661da8d17944", "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..173f35f01cf2 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 @@ -260,21 +262,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 +284,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 +298,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 +306,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 +437,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 +514,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 +527,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 +549,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 +562,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 +592,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 +683,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 +693,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 +707,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 +719,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 +732,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 +745,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 +767,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 +780,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 +814,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 +887,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 +912,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 +933,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 +1004,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 +1030,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,56 +1046,59 @@ 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" } 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..1e61332724ca 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 @@ -22,14 +22,12 @@ from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import Experiment -from ._models_py3 import ExperimentCancelOperationResult from ._models_py3 import ExperimentExecutionActionTargetDetailsError from ._models_py3 import ExperimentExecutionActionTargetDetailsProperties from ._models_py3 import ExperimentExecutionDetails from ._models_py3 import ExperimentExecutionDetailsListResult from ._models_py3 import ExperimentExecutionDetailsPropertiesRunInformation from ._models_py3 import ExperimentListResult -from ._models_py3 import ExperimentStartOperationResult from ._models_py3 import ExperimentStatus from ._models_py3 import ExperimentStatusListResult from ._models_py3 import ExperimentUpdate @@ -39,6 +37,7 @@ from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import OperationStatus from ._models_py3 import QuerySelector from ._models_py3 import Resource from ._models_py3 import ResourceIdentity @@ -60,6 +59,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 @@ -84,14 +84,12 @@ "ErrorDetail", "ErrorResponse", "Experiment", - "ExperimentCancelOperationResult", "ExperimentExecutionActionTargetDetailsError", "ExperimentExecutionActionTargetDetailsProperties", "ExperimentExecutionDetails", "ExperimentExecutionDetailsListResult", "ExperimentExecutionDetailsPropertiesRunInformation", "ExperimentListResult", - "ExperimentStartOperationResult", "ExperimentStatus", "ExperimentStatusListResult", "ExperimentUpdate", @@ -101,6 +99,7 @@ "Operation", "OperationDisplay", "OperationListResult", + "OperationStatus", "QuerySelector", "Resource", "ResourceIdentity", @@ -121,6 +120,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..33a55fb83dea 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 @@ -18,7 +18,7 @@ class Action(_serialization.Model): - """Model that represents the base action 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 @@ -103,7 +103,7 @@ def __init__(self, **kwargs: Any) -> None: class Branch(_serialization.Model): - """Model that represents a branch in the step. + """Model that represents a branch in the step. 9 total per experiment. All required parameters must be populated in order to send to Azure. @@ -115,7 +115,7 @@ class Branch(_serialization.Model): _validation = { "name": {"required": True, "min_length": 1}, - "actions": {"required": True, "min_items": 1}, + "actions": {"required": True, "max_items": 9, "min_items": 1}, } _attribute_map = { @@ -762,13 +762,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] :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 """ _validation = { @@ -777,7 +777,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,9 +790,9 @@ class Experiment(TrackedResource): "location": {"key": "location", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, "identity": {"key": "identity", "type": "ResourceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, "steps": {"key": "properties.steps", "type": "[Step]"}, "selectors": {"key": "properties.selectors", "type": "[Selector]"}, - "start_on_creation": {"key": "properties.startOnCreation", "type": "bool"}, } def __init__( @@ -802,7 +803,6 @@ def __init__( selectors: List["_models.Selector"], tags: Optional[Dict[str, str]] = None, identity: Optional["_models.ResourceIdentity"] = None, - start_on_creation: Optional[bool] = None, **kwargs: Any ) -> None: """ @@ -816,44 +816,13 @@ def __init__( :paramtype steps: list[~azure.mgmt.chaos.models.Step] :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 """ 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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: String of the Experiment name. - :vartype name: str - :ivar status_url: URL to retrieve the Experiment status. - :vartype status_url: str - """ - - _validation = { - "name": {"readonly": True}, - "status_url": {"readonly": True, "max_length": 2048}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status_url": {"key": "statusUrl", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.status_url = None class ExperimentExecutionActionTargetDetailsError(_serialization.Model): @@ -1083,34 +1052,6 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None -class ExperimentStartOperationResult(_serialization.Model): - """Model that represents the result of a start Experiment operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: String of the Experiment name. - :vartype name: str - :ivar status_url: URL to retrieve the Experiment status. - :vartype status_url: str - """ - - _validation = { - "name": {"readonly": True}, - "status_url": {"readonly": True, "max_length": 2048}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "status_url": {"key": "statusUrl", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.name = None - self.status_url = None - - class ExperimentStatus(_serialization.Model): """Model that represents the status of a Experiment. @@ -1350,7 +1291,7 @@ class ListSelector(Selector): _validation = { "type": {"required": True}, "id": {"required": True, "min_length": 1}, - "targets": {"required": True, "min_items": 1}, + "targets": {"required": True, "max_items": 50, "min_items": 1}, } _attribute_map = { @@ -1508,6 +1449,66 @@ def __init__(self, **kwargs: Any) -> None: self.next_link = None +class OperationStatus(_serialization.Model): + """The status of operation. + + :ivar id: The operation Id. + :vartype id: 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 + """ + + _attribute_map = { + "id": {"key": "id", "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: 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 id: The operation Id. + :paramtype id: 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__(**kwargs) + self.id = id + self.name = name + self.start_time = start_time + self.end_time = end_time + self.status = status + self.error = error + + class QuerySelector(Selector): """Model that represents a query selector. @@ -1703,7 +1704,7 @@ class Step(_serialization.Model): _validation = { "name": {"required": True, "min_length": 1}, - "branches": {"required": True, "min_items": 1}, + "branches": {"required": True, "max_items": 9, "min_items": 1}, } _attribute_map = { 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..a874f513ba37 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") @@ -378,7 +380,7 @@ def build_list_all_statuses_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 @@ -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") @@ -418,7 +420,7 @@ def build_get_status_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 @@ -447,7 +449,7 @@ def build_get_status_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") @@ -464,7 +466,7 @@ def build_list_execution_details_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 @@ -487,7 +489,7 @@ def build_list_execution_details_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") @@ -504,7 +506,7 @@ def build_get_execution_details_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 @@ -533,7 +535,7 @@ def build_get_execution_details_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") @@ -756,21 +758,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 +780,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 +794,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 +802,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 +933,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 +1010,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 +1023,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 +1044,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 +1057,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 +1086,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 +1175,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 +1185,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 +1199,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 +1211,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 +1224,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 +1237,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 +1258,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 +1271,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 +1304,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 +1376,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 +1401,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 +1422,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 +1493,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 +1519,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,56 +1535,59 @@ 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" } 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_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_aexperiment_execution_details.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution_details.py similarity index 92% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_execution_details.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution_details.py index 01f59c47e05c..a8a1bbe358a3 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_execution_details.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_execution_details.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_aexperiment_execution_details.py + python get_experiment_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, @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/GetAExperimentExecutionDetails.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/GetExperimentExecutionDetails.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/get_experiment_status.py similarity index 93% rename from sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_status.py rename to sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_status.py index f91455706470..b0e4db8f8ddd 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aexperiment_status.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_experiment_status.py @@ -14,7 +14,7 @@ pip install azure-identity pip install azure-mgmt-chaos # USAGE - python get_aexperiment_status.py + python get_experiment_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, @@ -37,6 +37,6 @@ def main(): 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/GetExperimentStatus.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_executions_details.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_executions_details.py index 942fe7a83d46..fc34da9d019a 100644 --- 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 @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-04-15-preview/examples/ListExperimentExecutionsDetails.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListExperimentExecutionsDetails.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_statuses.py index 3d782caa0b17..eb463d4e2e79 100644 --- a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_statuses.py +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_experiment_statuses.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/ListExperimentStatuses.json +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/stable/2023-11-01/examples/ListExperimentStatuses.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()