diff --git a/sdk/chaos/azure-mgmt-chaos/_meta.json b/sdk/chaos/azure-mgmt-chaos/_meta.json index 079f23a029db..c0e906175ef4 100644 --- a/sdk/chaos/azure-mgmt-chaos/_meta.json +++ b/sdk/chaos/azure-mgmt-chaos/_meta.json @@ -1,11 +1,11 @@ { - "commit": "e680f9bf4f154ec427ba7feac432ed8efd9665d0", + "commit": "295b4a63634e3a0c9f7e48d11c5c9ac7c386b9ea", "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..ff89b83d7dac 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,7 +19,9 @@ CapabilitiesOperations, CapabilityTypesOperations, ExperimentsOperations, + OperationStatusesOperations, Operations, + PrivateAccessesOperations, TargetTypesOperations, TargetsOperations, ) @@ -29,7 +31,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,8 +40,12 @@ 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 private_accesses: PrivateAccessesOperations operations + :vartype private_accesses: azure.mgmt.chaos.operations.PrivateAccessesOperations :ivar target_types: TargetTypesOperations operations :vartype target_types: azure.mgmt.chaos.operations.TargetTypesOperations :ivar targets: TargetsOperations operations @@ -50,9 +56,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 + :keyword api_version: Api Version. Default value is "2023-10-27-preview". 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,7 +84,13 @@ 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.private_accesses = PrivateAccessesOperations( + 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..9d26e41d8bfe 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 + :keyword api_version: Api Version. Default value is "2023-10-27-preview". 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-10-27-preview") 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..eaaa792650bf 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,7 +19,9 @@ CapabilitiesOperations, CapabilityTypesOperations, ExperimentsOperations, + OperationStatusesOperations, Operations, + PrivateAccessesOperations, TargetTypesOperations, TargetsOperations, ) @@ -29,7 +31,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,8 +40,12 @@ 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 private_accesses: PrivateAccessesOperations operations + :vartype private_accesses: azure.mgmt.chaos.aio.operations.PrivateAccessesOperations :ivar target_types: TargetTypesOperations operations :vartype target_types: azure.mgmt.chaos.aio.operations.TargetTypesOperations :ivar targets: TargetsOperations operations @@ -50,9 +56,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 + :keyword api_version: Api Version. Default value is "2023-10-27-preview". 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,7 +84,13 @@ 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.private_accesses = PrivateAccessesOperations( + 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..c67477926aa7 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 + :keyword api_version: Api Version. Default value is "2023-10-27-preview". 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-10-27-preview") 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..3c22387b1f86 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,7 +9,9 @@ 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 ._private_accesses_operations import PrivateAccessesOperations from ._target_types_operations import TargetTypesOperations from ._targets_operations import TargetsOperations @@ -21,7 +23,9 @@ "CapabilitiesOperations", "CapabilityTypesOperations", "ExperimentsOperations", + "OperationStatusesOperations", "Operations", + "PrivateAccessesOperations", "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..867a6db8bcb5 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,72 @@ 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 [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) + + deserialized = self._deserialize("Experiment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + @overload - async def create_or_update( + async def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -391,7 +510,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 +523,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 +545,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 +558,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 +588,75 @@ 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": "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_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 +678,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 +688,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 +702,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 +714,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 +727,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 +740,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 +762,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 +775,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 +809,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 +882,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 +907,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 +928,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 +999,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 +1025,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 +1041,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/aio/operations/_private_accesses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_private_accesses_operations.py new file mode 100644 index 000000000000..e392cb2c7b9f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/aio/operations/_private_accesses_operations.py @@ -0,0 +1,1266 @@ +# 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 io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +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.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 +from ...operations._private_accesses_operations import ( + build_create_or_update_request, + build_delete_a_private_endpoint_connection_request, + build_delete_request, + build_get_a_private_endpoint_connection_request, + build_get_private_link_resources_request, + build_get_request, + build_list_all_request, + build_list_private_endpoint_connections_request, + build_list_request, + build_update_a_private_endpoint_connection_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.aio.ChaosManagementClient`'s + :attr:`private_accesses` 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 + def list_all( + self, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PrivateAccess"]: + """Get a list of private access resources in a subscription. + + :param continuation_token_parameter: String that sets the continuation token. Default value is + None. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateAccess or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateAccessListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateAccessListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/privateAccesses"} + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.PrivateAccess"]: + """Get a list of private access resources in a resource group. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param continuation_token_parameter: String that sets the continuation token. Default value is + None. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateAccess or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateAccessListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateAccessListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> _models.PrivateAccess: + """Get a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :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.PrivateAccess] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + 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("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @overload + async def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: _models.PrivateAccessUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Required. + :type parameters: ~azure.mgmt.chaos.models.PrivateAccessUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: Union[_models.PrivateAccessUpdate, IO], + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Is either a PrivateAccessUpdate + type or a IO type. Required. + :type parameters: ~azure.mgmt.chaos.models.PrivateAccessUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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.PrivateAccess] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateAccessUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_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"], + 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("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: _models.PrivateAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Required. + :type private_access: ~azure.mgmt.chaos.models.PrivateAccess + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Required. + :type private_access: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: Union[_models.PrivateAccess, IO], + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Is either a + PrivateAccess type or a IO type. Required. + :type private_access: ~azure.mgmt.chaos.models.PrivateAccess or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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.PrivateAccess] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_access, (IOBase, bytes)): + _content = private_access + else: + _json = self._serialize.body(private_access, "PrivateAccess") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_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.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("PrivateAccess", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> None: + """Delete a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_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, + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.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, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @distributed_trace_async + async def get_private_link_resources( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateLinkResourceListResult + :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + request = build_get_private_link_resources_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resources.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("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateLinkResources" + } + + async def _update_a_private_endpoint_connection_initial( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + 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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_a_private_endpoint_connection_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, 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) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_a_private_endpoint_connection_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a + IO type. Required. + :type private_endpoint_connection: ~azure.mgmt.chaos.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :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.PrivateEndpointConnection] = 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_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + 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("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **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_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def get_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_a_private_endpoint_connection.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("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + 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[None] = kwargs.pop("cls", None) + + request = build_delete_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_a_private_endpoint_connection_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, 202, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + _delete_a_private_endpoint_connection_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a private endpoint connection under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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_a_private_endpoint_connection_initial( # type: ignore + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_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, **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_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_endpoint_connections_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_private_endpoint_connections.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections" + } 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..79ea7cba8be2 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,16 @@ from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import OperationStatus +from ._models_py3 import PrivateAccess +from ._models_py3 import PrivateAccessListResult +from ._models_py3 import PrivateAccessUpdate +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState from ._models_py3 import QuerySelector from ._models_py3 import Resource from ._models_py3 import ResourceIdentity @@ -60,6 +68,8 @@ 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 PrivateEndpointServiceConnectionStatus +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 +94,12 @@ "ErrorDetail", "ErrorResponse", "Experiment", - "ExperimentCancelOperationResult", "ExperimentExecutionActionTargetDetailsError", "ExperimentExecutionActionTargetDetailsProperties", "ExperimentExecutionDetails", "ExperimentExecutionDetailsListResult", "ExperimentExecutionDetailsPropertiesRunInformation", "ExperimentListResult", - "ExperimentStartOperationResult", "ExperimentStatus", "ExperimentStatusListResult", "ExperimentUpdate", @@ -101,6 +109,16 @@ "Operation", "OperationDisplay", "OperationListResult", + "OperationStatus", + "PrivateAccess", + "PrivateAccessListResult", + "PrivateAccessUpdate", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", "QuerySelector", "Resource", "ResourceIdentity", @@ -121,6 +139,8 @@ "CreatedByType", "FilterType", "Origin", + "PrivateEndpointServiceConnectionStatus", + "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..61b8bdb96d26 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,25 @@ class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_SYSTEM = "user,system" +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +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..fcae10829117 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 @@ -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,6 +777,7 @@ class Experiment(TrackedResource): "type": {"readonly": True}, "location": {"required": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, "steps": {"required": True, "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": "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. @@ -1508,6 +1449,400 @@ 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 PrivateAccess(TrackedResource): + """PrivateAccesses tracked resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar system_data: The system metadata of the private access resource. + :vartype system_data: ~azure.mgmt.chaos.models.SystemData + :ivar location: Location of the private access resource. + :vartype location: str + :ivar private_endpoint_connections: A readonly collection of private endpoint connection. + Currently only one endpoint connection is supported. + :vartype private_endpoint_connections: list[~azure.mgmt.chaos.models.PrivateEndpointConnection] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Location of the private access resource. + :paramtype location: str + """ + super().__init__(tags=tags, **kwargs) + self.system_data = None + self.location = location + self.private_endpoint_connections = None + + +class PrivateAccessListResult(_serialization.Model): + """Model that represents a list of private access resources and a link for pagination. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of private access resources. + :vartype value: list[~azure.mgmt.chaos.models.PrivateAccess] + :ivar next_link: URL to retrieve the next page of private access resources. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True, "max_length": 2048}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateAccess]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateAccessUpdate(_serialization.Model): + """An update to a private access. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(_serialization.Model): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: private endpoint connection Id. + :vartype id: str + :ivar name: private endpoint connection name. + :vartype name: str + :ivar type: private endpoint connection type. + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.chaos.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between PrivateAccess and Virtual Network. + :vartype private_link_service_connection_state: + ~azure.mgmt.chaos.models.PrivateLinkServiceConnectionState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "private_endpoint": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + } + + def __init__( + self, + *, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between PrivateAccess and Virtual Network. + :paramtype private_link_service_connection_state: + ~azure.mgmt.chaos.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.private_endpoint = None + self.private_link_service_connection_state = private_link_service_connection_state + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :ivar next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to + fetch the next page of snapshots. + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :keyword next_link: The uri to fetch the next page of snapshots. Call ListNext() with this to + fetch the next page of snapshots. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class PrivateLinkResource(_serialization.Model): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: private link resource Id. + :vartype id: str + :ivar name: private link resource name. + :vartype name: str + :ivar type: private link resource type. + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword required_zone_names: The private link resource DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.chaos.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.chaos.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and + provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or ~azure.mgmt.chaos.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype actions_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + actions_required: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or ~azure.mgmt.chaos.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword actions_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype actions_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.actions_required = actions_required + + class QuerySelector(Selector): """Model that represents a query selector. 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..3c22387b1f86 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,7 +9,9 @@ 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 ._private_accesses_operations import PrivateAccessesOperations from ._target_types_operations import TargetTypesOperations from ._targets_operations import TargetsOperations @@ -21,7 +23,9 @@ "CapabilitiesOperations", "CapabilityTypesOperations", "ExperimentsOperations", + "OperationStatusesOperations", "Operations", + "PrivateAccessesOperations", "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..a3fbe4d1e408 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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..76ced70ef8ca 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-10-27-preview")) 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-10-27-preview")) 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..a01338708e3f 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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,72 @@ 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 [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) + + deserialized = self._deserialize("Experiment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}" + } + @overload - def create_or_update( + def begin_create_or_update( self, resource_group_name: str, experiment_name: str, @@ -887,7 +1006,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 +1019,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 +1040,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 +1053,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 +1082,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": "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_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 +1171,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 +1181,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 +1195,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 +1207,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 +1220,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 +1233,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 +1254,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 +1267,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 +1300,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 +1372,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 +1397,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 +1418,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 +1489,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 +1515,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 +1531,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..72bdcb1805d9 --- /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-10-27-preview")) + 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..6d1a9cfa160f 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-10-27-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL diff --git a/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_private_accesses_operations.py b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_private_accesses_operations.py new file mode 100644 index 000000000000..a7704c8aba7f --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/azure/mgmt/chaos/operations/_private_accesses_operations.py @@ -0,0 +1,1721 @@ +# 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 io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_all_request( + subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **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-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/privateAccesses") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, subscription_id: str, *, continuation_token_parameter: Optional[str] = None, **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-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if continuation_token_parameter is not None: + _params["continuationToken"] = _SERIALIZER.query( + "continuation_token_parameter", continuation_token_parameter, "str" + ) + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _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) + + +def build_update_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_private_link_resources_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _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) + + +def build_update_a_private_endpoint_connection_request( + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_a_private_endpoint_connection_request( + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _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) + + +def build_delete_a_private_endpoint_connection_request( + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_private_endpoint_connections_request( + resource_group_name: str, private_access_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-27-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", + subscription_id, + "str", + pattern=r"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", pattern=r"^[a-zA-Z0-9_\-\.\(\)]*[a-zA-Z0-9_\-\(\)]$" + ), + "privateAccessName": _SERIALIZER.url( + "private_access_name", private_access_name, "str", min_length=1, pattern=r"^[^<>%&:?#/\\]+$" + ), + } + + _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 PrivateAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.chaos.ChaosManagementClient`'s + :attr:`private_accesses` 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 list_all( + self, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PrivateAccess"]: + """Get a list of private access resources in a subscription. + + :param continuation_token_parameter: String that sets the continuation token. Default value is + None. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateAccessListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateAccessListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Chaos/privateAccesses"} + + @distributed_trace + def list( + self, resource_group_name: str, continuation_token_parameter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.PrivateAccess"]: + """Get a list of private access resources in a resource group. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param continuation_token_parameter: String that sets the continuation token. Default value is + None. + :type continuation_token_parameter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateAccess or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateAccess] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateAccessListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + continuation_token_parameter=continuation_token_parameter, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateAccessListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses" + } + + @distributed_trace + def get(self, resource_group_name: str, private_access_name: str, **kwargs: Any) -> _models.PrivateAccess: + """Get a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :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.PrivateAccess] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + 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("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @overload + def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: _models.PrivateAccessUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Required. + :type parameters: ~azure.mgmt.chaos.models.PrivateAccessUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + private_access_name: str, + parameters: Union[_models.PrivateAccessUpdate, IO], + **kwargs: Any + ) -> _models.PrivateAccess: + """Updates an private access instance. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param parameters: The update to the private access instance. Is either a PrivateAccessUpdate + type or a IO type. Required. + :type parameters: ~azure.mgmt.chaos.models.PrivateAccessUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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.PrivateAccess] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateAccessUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_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"], + 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("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: _models.PrivateAccess, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Required. + :type private_access: ~azure.mgmt.chaos.models.PrivateAccess + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Required. + :type private_access: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + 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: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + private_access_name: str, + private_access: Union[_models.PrivateAccess, IO], + **kwargs: Any + ) -> _models.PrivateAccess: + """Create or update a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_access: private access resource to be created or updated. Is either a + PrivateAccess type or a IO type. Required. + :type private_access: ~azure.mgmt.chaos.models.PrivateAccess or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateAccess or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateAccess + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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.PrivateAccess] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_access, (IOBase, bytes)): + _content = private_access + else: + _json = self._serialize.body(private_access, "PrivateAccess") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_access_name=private_access_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.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("PrivateAccess", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateAccess", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> None: + """Delete a private access. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_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, + 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[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.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, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}" + } + + @distributed_trace + def get_private_link_resources( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources possible under private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateLinkResourceListResult + :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.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + request = build_get_private_link_resources_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resources.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("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_private_link_resources.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateLinkResources" + } + + def _update_a_private_endpoint_connection_initial( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + 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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IOBase, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_a_private_endpoint_connection_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, 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) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_a_private_endpoint_connection_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Required. + :type private_endpoint_connection: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_a_private_endpoint_connection( + self, + resource_group_name: str, + private_access_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection under private access resource, this can't be + used to create a new private endpoint connection. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: private endpoint connection object supplied in the body of + the Put private endpoint connection operation. Is either a PrivateEndpointConnection type or a + IO type. Required. + :type private_endpoint_connection: ~azure.mgmt.chaos.models.PrivateEndpointConnection or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :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.PrivateEndpointConnection] = 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_a_private_endpoint_connection_initial( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + private_endpoint_connection=private_endpoint_connection, + 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("PrivateEndpointConnection", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **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_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def get_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets information about a private endpoint connection under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.chaos.models.PrivateEndpointConnection + :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.PrivateEndpointConnection] = kwargs.pop("cls", None) + + request = build_get_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_a_private_endpoint_connection.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("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + 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[None] = kwargs.pop("cls", None) + + request = build_delete_a_private_endpoint_connection_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_a_private_endpoint_connection_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, 202, 204]: + 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 cls: + return cls(pipeline_response, None, {}) + + _delete_a_private_endpoint_connection_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete_a_private_endpoint_connection( + self, resource_group_name: str, private_access_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes a private endpoint connection under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_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_a_private_endpoint_connection_initial( # type: ignore + resource_group_name=resource_group_name, + private_access_name=private_access_name, + private_endpoint_connection_name=private_endpoint_connection_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, **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_a_private_endpoint_connection.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def list_private_endpoint_connections( + self, resource_group_name: str, private_access_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List information about private endpoint connections under a private access resource. + + :param resource_group_name: String that represents an Azure resource group. Required. + :type resource_group_name: str + :param private_access_name: The name of the private access resource that is being created. + Supported characters for the name are a-z, A-Z, 0-9, _ and -. The maximum name length is 80 + characters. Required. + :type private_access_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.chaos.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_private_endpoint_connections_request( + resource_group_name=resource_group_name, + private_access_name=private_access_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_private_endpoint_connections.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/privateAccesses/{privateAccessName}/privateEndpointConnections" + } 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..46fc06c8e583 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-10-27-preview")) 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-10-27-preview")) 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..27bf8e88883a 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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-10-27-preview")) 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..9789897aee89 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/preview/2023-10-27-preview/examples/CancelExperiment.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aprivate_access.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aprivate_access.py new file mode 100644 index 000000000000..615ab0d8578c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/create_or_update_aprivate_access.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python create_or_update_aprivate_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.create_or_update( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_access={"location": "centraluseuap", "properties": {}}, + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/CreateOrUpdateAPrivateAccess.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..12bace0fab70 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/preview/2023-10-27-preview/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..3a849ba9567f 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/preview/2023-10-27-preview/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..734458d92a2e 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/preview/2023-10-27-preview/examples/CreateUpdateTarget.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aprivate_access.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aprivate_access.py new file mode 100644 index 000000000000..12b38999659c --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/delete_aprivate_access.py @@ -0,0 +1,40 @@ +# 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 delete_aprivate_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + client.private_accesses.delete( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/DeleteAPrivateAccess.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..ce784c61d4d3 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/preview/2023-10-27-preview/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..d80ada41b50a 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/preview/2023-10-27-preview/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..31cb9fd30add 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/preview/2023-10-27-preview/examples/DeleteTarget.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access.py new file mode 100644 index 000000000000..fc8c06d24af0 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access.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_aprivate_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.get( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/GetAPrivateAccess.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access_with_private_endpoint.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access_with_private_endpoint.py new file mode 100644 index 000000000000..e95f68f20f33 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/get_aprivate_access_with_private_endpoint.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_aprivate_access_with_private_endpoint.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.get( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/GetAPrivateAccess_WithPrivateEndpoint.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..f45f8125fa82 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/preview/2023-10-27-preview/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..4d06a720dcb0 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/preview/2023-10-27-preview/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..045ef3b00abd 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/preview/2023-10-27-preview/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..7649cb0380a4 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/preview/2023-10-27-preview/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..e32aa129f9b5 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/preview/2023-10-27-preview/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..4643f70b29cf --- /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/preview/2023-10-27-preview/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..5ceb70763cbf 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/preview/2023-10-27-preview/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..56cb8be3d3fc 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/preview/2023-10-27-preview/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..56da013cf996 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/preview/2023-10-27-preview/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..968553e1af3b 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/preview/2023-10-27-preview/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..d988c9e73a86 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/preview/2023-10-27-preview/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..15338f20a7e1 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/preview/2023-10-27-preview/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..560d595ed7a7 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/preview/2023-10-27-preview/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..166ef9e45924 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/preview/2023-10-27-preview/examples/ListExperimentsInASubscription.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_aresource_group.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_aresource_group.py new file mode 100644 index 000000000000..86be708837fe --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_aresource_group.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 list_private_access_in_aresource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.list( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/ListPrivateAccessInAResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_asubscription.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_asubscription.py new file mode 100644 index 000000000000..bcee6b93cc5b --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/list_private_access_in_asubscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python list_private_access_in_asubscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.list_all() + for item in response: + print(item) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/ListPrivateAccessInASubscription.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..055e883e2d98 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/preview/2023-10-27-preview/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..33b1d46e073f 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/preview/2023-10-27-preview/examples/ListTargets.json if __name__ == "__main__": main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_patch_update.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_patch_update.py new file mode 100644 index 000000000000..4813bd6b260e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_patch_update.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_access_patch_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.update( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + parameters={"tags": {"key1": "value1"}}, + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPatchUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_approve.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_approve.py new file mode 100644 index 000000000000..c728faaf24a5 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_approve.py @@ -0,0 +1,50 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_access_private_endpoint_connection_approve.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.begin_update_a_private_endpoint_connection( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_endpoint_connection_name="myPrivateEndpointConnection", + private_endpoint_connection={ + "properties": { + "privateLinkServiceConnectionState": { + "description": "Approving myPrivateEndpointConnection", + "status": "Approved", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPrivateEndpointConnection_Approve.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_delete.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_delete.py new file mode 100644 index 000000000000..79148f3dbefa --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_delete.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 private_access_private_endpoint_connection_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + client.private_accesses.begin_delete_a_private_endpoint_connection( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_endpoint_connection_name="myPrivateEndpointConnection", + ).result() + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPrivateEndpointConnection_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_get.py new file mode 100644 index 000000000000..ea78086144c8 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_access_private_endpoint_connection_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.get_a_private_endpoint_connection( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + private_endpoint_connection_name="myPrivateEndpointConnection", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPrivateEndpointConnection_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_list_by_private_access.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_list_by_private_access.py new file mode 100644 index 000000000000..f8af8ed5c926 --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_endpoint_connection_list_by_private_access.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.chaos import ChaosManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-chaos +# USAGE + python private_access_private_endpoint_connection_list_by_private_access.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.list_private_endpoint_connections( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPrivateEndpointConnection_ListByPrivateAccess.json +if __name__ == "__main__": + main() diff --git a/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_link_resources_get.py b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_link_resources_get.py new file mode 100644 index 000000000000..5a309122328e --- /dev/null +++ b/sdk/chaos/azure-mgmt-chaos/generated_samples/private_access_private_link_resources_get.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 private_access_private_link_resources_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = ChaosManagementClient( + credential=DefaultAzureCredential(), + subscription_id="6b052e15-03d3-4f17-b2e1-be7f07588291", + ) + + response = client.private_accesses.get_private_link_resources( + resource_group_name="myResourceGroup", + private_access_name="myPrivateAccess", + ) + print(response) + + +# x-ms-original-file: specification/chaos/resource-manager/Microsoft.Chaos/preview/2023-10-27-preview/examples/PrivateAccessPrivateLinkResources_Get.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..824094053dcb 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/preview/2023-10-27-preview/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..8743949280cd 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/preview/2023-10-27-preview/examples/UpdateExperiment.json if __name__ == "__main__": main()