diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/_meta.json b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/_meta.json index 639262301bed..e7ad9835125e 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/_meta.json +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/_meta.json @@ -1,11 +1,11 @@ { - "commit": "51a6e410cf9752dfdaad71f0f9778645d737d8c4", + "commit": "57db2afee49a5715344fc5fc0099fe29bba3c984", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/hardwaresecuritymodules/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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/hardwaresecuritymodules/resource-manager/readme.md --generate-sample=True --generate-test=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.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/hardwaresecuritymodules/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_configuration.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_configuration.py index 36a42bfc8ff4..08c66e9f809d 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_configuration.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class HardwareSecurityModulesMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class HardwareSecurityModulesMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for HardwareSecurityModulesMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,10 +28,14 @@ class HardwareSecurityModulesMgmtClientConfiguration(Configuration): # pylint: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2025-03-31". 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(HardwareSecurityModulesMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2025-03-31") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -40,8 +43,10 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.credential = credential self.subscription_id = subscription_id + self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-hardwaresecuritymodules/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_hardware_security_modules_mgmt_client.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_hardware_security_modules_mgmt_client.py index e8b1d560336b..9b2be489384f 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_hardware_security_modules_mgmt_client.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_hardware_security_modules_mgmt_client.py @@ -8,16 +8,21 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import HardwareSecurityModulesMgmtClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + CloudHsmClusterBackupStatusOperations, CloudHsmClusterPrivateEndpointConnectionsOperations, CloudHsmClusterPrivateLinkResourcesOperations, + CloudHsmClusterRestoreStatusOperations, CloudHsmClustersOperations, DedicatedHsmOperations, Operations, @@ -29,7 +34,7 @@ from azure.core.credentials import TokenCredential -class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure HSM RP. @@ -47,16 +52,25 @@ class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-v :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.hardwaresecuritymodules.operations.PrivateEndpointConnectionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.hardwaresecuritymodules.operations.Operations + :ivar cloud_hsm_cluster_backup_status: CloudHsmClusterBackupStatusOperations operations + :vartype cloud_hsm_cluster_backup_status: + azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterBackupStatusOperations + :ivar cloud_hsm_cluster_restore_status: CloudHsmClusterRestoreStatusOperations operations + :vartype cloud_hsm_cluster_restore_status: + azure.mgmt.hardwaresecuritymodules.operations.CloudHsmClusterRestoreStatusOperations :ivar dedicated_hsm: DedicatedHsmOperations operations :vartype dedicated_hsm: azure.mgmt.hardwaresecuritymodules.operations.DedicatedHsmOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.hardwaresecuritymodules.operations.Operations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :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 "2025-03-31". 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. """ @@ -71,7 +85,25 @@ def __init__( self._config = HardwareSecurityModulesMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -89,10 +121,16 @@ def __init__( self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_hsm_cluster_backup_status = CloudHsmClusterBackupStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_hsm_cluster_restore_status = CloudHsmClusterRestoreStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dedicated_hsm = DedicatedHsmOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -112,12 +150,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "HardwareSecurityModulesMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_serialization.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_serialization.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :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 + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return 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) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_vendor.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_version.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_version.py index e5754a47ce68..dfa6ee022f15 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_version.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_configuration.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_configuration.py index cf7f15c78ff9..89b04d0f5536 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_configuration.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class HardwareSecurityModulesMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class HardwareSecurityModulesMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for HardwareSecurityModulesMgmtClient. Note that all parameters used to create this instance are saved as instance @@ -29,10 +28,14 @@ class HardwareSecurityModulesMgmtClientConfiguration(Configuration): # pylint: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2025-03-31". 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(HardwareSecurityModulesMgmtClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2025-03-31") + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -40,8 +43,10 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.credential = credential self.subscription_id = subscription_id + self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-hardwaresecuritymodules/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_hardware_security_modules_mgmt_client.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_hardware_security_modules_mgmt_client.py index aff9a3d066d7..3d7ff6b37749 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_hardware_security_modules_mgmt_client.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/_hardware_security_modules_mgmt_client.py @@ -8,16 +8,21 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import HardwareSecurityModulesMgmtClientConfiguration from .operations import ( + CloudHsmClusterBackupStatusOperations, CloudHsmClusterPrivateEndpointConnectionsOperations, CloudHsmClusterPrivateLinkResourcesOperations, + CloudHsmClusterRestoreStatusOperations, CloudHsmClustersOperations, DedicatedHsmOperations, Operations, @@ -29,7 +34,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-version-keyword +class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure management API provides a RESTful set of web services that interact with Azure HSM RP. @@ -47,17 +52,26 @@ class HardwareSecurityModulesMgmtClient: # pylint: disable=client-accepts-api-v :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations :vartype private_endpoint_connections: azure.mgmt.hardwaresecuritymodules.aio.operations.PrivateEndpointConnectionsOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.hardwaresecuritymodules.aio.operations.Operations + :ivar cloud_hsm_cluster_backup_status: CloudHsmClusterBackupStatusOperations operations + :vartype cloud_hsm_cluster_backup_status: + azure.mgmt.hardwaresecuritymodules.aio.operations.CloudHsmClusterBackupStatusOperations + :ivar cloud_hsm_cluster_restore_status: CloudHsmClusterRestoreStatusOperations operations + :vartype cloud_hsm_cluster_restore_status: + azure.mgmt.hardwaresecuritymodules.aio.operations.CloudHsmClusterRestoreStatusOperations :ivar dedicated_hsm: DedicatedHsmOperations operations :vartype dedicated_hsm: azure.mgmt.hardwaresecuritymodules.aio.operations.DedicatedHsmOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.hardwaresecuritymodules.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :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 "2025-03-31". 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. """ @@ -72,7 +86,25 @@ def __init__( self._config = HardwareSecurityModulesMgmtClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -90,10 +122,18 @@ def __init__( self.private_endpoint_connections = PrivateEndpointConnectionsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_hsm_cluster_backup_status = CloudHsmClusterBackupStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_hsm_cluster_restore_status = CloudHsmClusterRestoreStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dedicated_hsm = DedicatedHsmOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -113,12 +153,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "HardwareSecurityModulesMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/__init__.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/__init__.py index f36ee4ea2e1f..0101fac8d086 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/__init__.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/__init__.py @@ -12,8 +12,10 @@ CloudHsmClusterPrivateEndpointConnectionsOperations, ) from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._operations import Operations +from ._cloud_hsm_cluster_backup_status_operations import CloudHsmClusterBackupStatusOperations +from ._cloud_hsm_cluster_restore_status_operations import CloudHsmClusterRestoreStatusOperations from ._dedicated_hsm_operations import DedicatedHsmOperations +from ._operations import Operations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -24,8 +26,10 @@ "CloudHsmClusterPrivateLinkResourcesOperations", "CloudHsmClusterPrivateEndpointConnectionsOperations", "PrivateEndpointConnectionsOperations", - "Operations", + "CloudHsmClusterBackupStatusOperations", + "CloudHsmClusterRestoreStatusOperations", "DedicatedHsmOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_backup_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_backup_status_operations.py new file mode 100644 index 000000000000..bce295cb2134 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_backup_status_operations.py @@ -0,0 +1,125 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, 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 ...operations._cloud_hsm_cluster_backup_status_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudHsmClusterBackupStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hardwaresecuritymodules.aio.HardwareSecurityModulesMgmtClient`'s + :attr:`cloud_hsm_cluster_backup_status` 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, resource_group_name: str, cloud_hsm_cluster_name: str, job_id: str, **kwargs: Any + ) -> Optional[_models.BackupResult]: + """Gets the backup operation status of the specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param job_id: The id returned as part of the backup request. Required. + :type job_id: str + :return: BackupResult or None or the result of cls(response) + :rtype: ~azure.mgmt.hardwaresecuritymodules.models.BackupResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Optional[_models.BackupResult]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py index 4bd637f87426..024d81f970f7 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # 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, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,30 +16,34 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._cloud_hsm_cluster_private_endpoint_connections_operations import ( build_create_request, build_delete_request, build_get_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CloudHsmClusterPrivateEndpointConnectionsOperations: +class CloudHsmClusterPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -74,7 +79,7 @@ async def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. @@ -84,7 +89,6 @@ async def create( :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: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -96,7 +100,7 @@ async def create( resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -107,17 +111,16 @@ async def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_connection_name: str :param properties: Parameters of the PrivateEndpointConnection. Required. - :type properties: IO + :type properties: IO[bytes] :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: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -129,7 +132,7 @@ async def create( resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates the private endpoint connection for the Cloud Hsm Cluster. @@ -138,23 +141,20 @@ async def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_connection_name: str :param properties: Parameters of the PrivateEndpointConnection. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.hardwaresecuritymodules.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 + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection or + IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -165,7 +165,7 @@ async def create( _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-12-10-preview")) + 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) @@ -177,7 +177,7 @@ async def create( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, @@ -186,40 +186,34 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -230,44 +224,47 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -279,19 +276,11 @@ async def begin_delete( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_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: @@ -299,13 +288,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, @@ -315,11 +304,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -330,17 +320,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -352,17 +338,16 @@ async def get( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_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.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,41 +358,35 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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_request( + _request = build_get_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_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) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_link_resources_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_link_resources_operations.py index e3d8cb0ba12b..3b49dc09e053 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_link_resources_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,11 @@ # 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 +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -17,21 +20,23 @@ 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.rest import AsyncHttpResponse, 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 ..._vendor import _convert_request from ...operations._cloud_hsm_cluster_private_link_resources_operations import build_list_by_cloud_hsm_cluster_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CloudHsmClusterPrivateLinkResourcesOperations: +class CloudHsmClusterPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -50,24 +55,30 @@ def __init__(self, *args, **kwargs) -> None: 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 list_by_cloud_hsm_cluster( + @distributed_trace + def list_by_cloud_hsm_cluster( self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Gets the private link resources supported for the Cloud Hsm Cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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.hardwaresecuritymodules.models.PrivateLinkResourceListResult + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + _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) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -75,43 +86,57 @@ async def list_by_cloud_hsm_cluster( } 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", "2023-12-10-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - request = build_list_by_cloud_hsm_cluster_request( - resource_group_name=resource_group_name, - cloud_hsm_cluster_name=cloud_hsm_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_cloud_hsm_cluster.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.CloudHsmClusterError, 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 - - list_by_cloud_hsm_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateLinkResources" - } + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cloud_hsm_cluster_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", 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) diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_restore_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_restore_status_operations.py new file mode 100644 index 000000000000..dfeaec76b0aa --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_cluster_restore_status_operations.py @@ -0,0 +1,125 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, 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 ...operations._cloud_hsm_cluster_restore_status_operations import build_get_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class CloudHsmClusterRestoreStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hardwaresecuritymodules.aio.HardwareSecurityModulesMgmtClient`'s + :attr:`cloud_hsm_cluster_restore_status` 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, resource_group_name: str, cloud_hsm_cluster_name: str, job_id: str, **kwargs: Any + ) -> Optional[_models.RestoreResult]: + """Gets the restore operation status of the specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param job_id: The id returned as part of the backup request. Required. + :type job_id: str + :return: RestoreResult or None or the result of cls(response) + :rtype: ~azure.mgmt.hardwaresecuritymodules.models.RestoreResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Optional[_models.RestoreResult]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_clusters_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_clusters_operations.py index 8d7472127d37..bdf770314559 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_clusters_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_cloud_hsm_clusters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -15,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -28,16 +32,23 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._cloud_hsm_clusters_operations import ( + build_backup_request, build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, + build_restore_request, build_update_request, + build_validate_backup_properties_request, + build_validate_restore_properties_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,12 +78,12 @@ async def _create_or_update_initial( cloud_hsm_cluster_name: str, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, + sku: Optional[_models.CloudHsmClusterSku] = None, properties: Optional[_models.CloudHsmClusterProperties] = None, **kwargs: Any - ) -> _models.CloudHsmCluster: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,54 +94,49 @@ async def _create_or_update_initial( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _body = _models.CloudHsmCluster(identity=identity, location=location, properties=properties, sku=sku, tags=tags) _json = self._serialize.body(_body, "CloudHsmCluster") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + 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("CloudHsmCluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } - @distributed_trace_async async def begin_create_or_update( self, @@ -138,8 +144,8 @@ async def begin_create_or_update( cloud_hsm_cluster_name: str, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, + sku: Optional[_models.CloudHsmClusterSku] = None, properties: Optional[_models.CloudHsmClusterProperties] = None, **kwargs: Any ) -> AsyncLROPoller[_models.CloudHsmCluster]: @@ -149,27 +155,19 @@ async def begin_create_or_update( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param location: The geo-location where the resource lives. Required. :type location: str :param tags: Resource tags. Default value is None. :type tags: dict[str, str] - :param sku: SKU details. Default value is None. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param identity: Managed service identity (system assigned and/or user assigned identities). Default value is None. :type identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :param sku: SKU details. Default value is None. + :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param properties: Properties of the Cloud HSM Cluster. Default value is None. :type properties: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterProperties - :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 CloudHsmCluster or the result of cls(response) :rtype: @@ -179,7 +177,7 @@ async def begin_create_or_update( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -191,8 +189,8 @@ async def begin_create_or_update( cloud_hsm_cluster_name=cloud_hsm_cluster_name, location=location, tags=tags, - sku=sku, identity=identity, + sku=sku, properties=properties, api_version=api_version, content_type=content_type, @@ -201,12 +199,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -219,29 +218,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CloudHsmCluster].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return AsyncLROPoller[_models.CloudHsmCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, cloud_hsm_cluster_name: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, - properties: Optional[_models.CloudHsmClusterPatchParametersProperties] = None, **kwargs: Any - ) -> Optional[_models.CloudHsmCluster]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -252,55 +247,52 @@ async def _update_initial( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[Optional[_models.CloudHsmCluster]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _body = _models.CloudHsmClusterPatchParameters(identity=identity, properties=properties, sku=sku, tags=tags) + _body = _models.CloudHsmClusterPatchParameters(identity=identity, tags=tags) _json = self._serialize.body(_body, "CloudHsmClusterPatchParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_update( @@ -308,9 +300,7 @@ async def begin_update( resource_group_name: str, cloud_hsm_cluster_name: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, - properties: Optional[_models.CloudHsmClusterPatchParametersProperties] = None, **kwargs: Any ) -> AsyncLROPoller[_models.CloudHsmCluster]: """Update a Cloud HSM Cluster in the specified subscription. @@ -319,26 +309,13 @@ async def begin_update( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param tags: The Cloud HSM Cluster's tags. Default value is None. :type tags: dict[str, str] - :param sku: SKU details. Default value is None. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param identity: Managed service identity (system assigned and/or user assigned identities). Default value is None. :type identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity - :param properties: Properties of the Cloud HSM Cluster. Default value is None. - :type properties: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterPatchParametersProperties - :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 CloudHsmCluster or the result of cls(response) :rtype: @@ -348,7 +325,7 @@ async def begin_update( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -359,9 +336,7 @@ async def begin_update( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, tags=tags, - sku=sku, identity=identity, - properties=properties, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -369,12 +344,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -386,17 +362,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CloudHsmCluster].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return AsyncLROPoller[_models.CloudHsmCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get( @@ -408,14 +382,13 @@ async def get( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CloudHsmCluster or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -426,48 +399,42 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_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) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -478,43 +445,46 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -526,16 +496,8 @@ async def begin_delete( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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: @@ -543,13 +505,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 + raw_result = await self._delete_initial( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, api_version=api_version, @@ -558,11 +520,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -573,17 +536,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_by_resource_group( @@ -598,7 +557,6 @@ def list_by_resource_group( :param skiptoken: The page-continuation token to use with a paged version of this API. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CloudHsmCluster or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster] @@ -607,10 +565,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -621,24 +579,32 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skiptoken=skiptoken, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CloudHsmClusterListResult", pipeline_response) @@ -648,27 +614,23 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters" - } - @distributed_trace def list_by_subscription( self, skiptoken: Optional[str] = None, **kwargs: Any @@ -679,7 +641,6 @@ def list_by_subscription( :param skiptoken: The page-continuation token to use with a paged version of this API. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CloudHsmCluster or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster] @@ -688,10 +649,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -702,23 +663,31 @@ def list_by_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, skiptoken=skiptoken, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("CloudHsmClusterListResult", pipeline_response) @@ -728,23 +697,914 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters" - } + async def _validate_backup_properties_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(backup_request_properties, (IOBase, bytes)): + _content = backup_request_properties + else: + if backup_request_properties is not None: + _json = self._serialize.body(backup_request_properties, "BackupRequestProperties") + else: + _json = None + + _request = build_validate_backup_properties_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[_models.BackupRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Default value is None. + :type backup_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Is either a + BackupRequestProperties type or a IO[bytes] type. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :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.BackupResult] = 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._validate_backup_properties_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + backup_request_properties=backup_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _backup_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(backup_request_properties, (IOBase, bytes)): + _content = backup_request_properties + else: + if backup_request_properties is not None: + _json = self._serialize.body(backup_request_properties, "BackupRequestProperties") + else: + _json = None + + _request = build_backup_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[_models.BackupRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Default value is None. + :type backup_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Is either a + BackupRequestProperties type or a IO[bytes] type. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either BackupResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :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.BackupResult] = 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._backup_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + backup_request_properties=backup_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.BackupResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.BackupResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _validate_restore_properties_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[Union[_models.RestoreRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(restore_request_properties, (IOBase, bytes)): + _content = restore_request_properties + else: + if restore_request_properties is not None: + _json = self._serialize.body(restore_request_properties, "RestoreRequestProperties") + else: + _json = None + + _request = build_validate_restore_properties_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[_models.RestoreRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Default value is None. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Default value is None. + :type restore_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[Union[_models.RestoreRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Is either a RestoreRequestProperties type or a IO[bytes] type. Default value is + None. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :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.RestoreResult] = 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._validate_restore_properties_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + restore_request_properties=restore_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RestoreResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RestoreResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _restore_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Union[_models.RestoreRequestProperties, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(restore_request_properties, (IOBase, bytes)): + _content = restore_request_properties + else: + _json = self._serialize.body(restore_request_properties, "RestoreRequestProperties") + + _request = build_restore_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: _models.RestoreRequestProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Required. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Required. + :type restore_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Union[_models.RestoreRequestProperties, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Is either a + RestoreRequestProperties type or a IO[bytes] type. Required. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties or IO[bytes] + :return: An instance of AsyncLROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :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.RestoreResult] = 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._restore_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + restore_request_properties=restore_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.RestoreResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.RestoreResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py index b699d65b1fcf..002c5756b380 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_dedicated_hsm_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,9 @@ # 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 sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, 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 @@ -29,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._dedicated_hsm_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +42,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,9 +70,9 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_or_update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO], **kwargs: Any - ) -> _models.DedicatedHsm: - error_map = { + self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -77,9 +83,9 @@ async def _create_or_update_initial( _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", "2021-11-30")) + 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.DedicatedHsm] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -89,7 +95,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DedicatedHsm") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, @@ -97,40 +103,35 @@ async def _create_or_update_initial( 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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DedicatedHsm", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } - @overload async def begin_create_or_update( self, @@ -143,7 +144,7 @@ async def begin_create_or_update( ) -> AsyncLROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. @@ -153,14 +154,6 @@ async def begin_create_or_update( :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 DedicatedHsm or the result of cls(response) :rtype: @@ -173,31 +166,23 @@ async def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. :type name: str :param parameters: Parameters to create or update the dedicated hsm. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DedicatedHsm or the result of cls(response) :rtype: @@ -207,29 +192,18 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO], **kwargs: Any + self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. :type name: str :param parameters: Parameters to create or update the dedicated hsm. Is either a DedicatedHsm - type or a IO type. Required. - :type parameters: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm 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. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm or IO[bytes] :return: An instance of AsyncLROPoller that returns either DedicatedHsm or the result of cls(response) :rtype: @@ -239,7 +213,7 @@ async def begin_create_or_update( _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", "2021-11-30")) + 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.DedicatedHsm] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -257,12 +231,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -272,22 +247,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DedicatedHsm].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return AsyncLROPoller[_models.DedicatedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, name: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> _models.DedicatedHsm: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -298,49 +271,52 @@ async def _update_initial( _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _parameters = _models.DedicatedHsmPatchParameters(tags=tags) _json = self._serialize.body(_parameters, "DedicatedHsmPatchParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, {}) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_update( @@ -348,21 +324,13 @@ async def begin_update( ) -> AsyncLROPoller[_models.DedicatedHsm]: """Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the server belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: Name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str :param tags: Resource tags. Default value is None. :type tags: dict[str, 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 DedicatedHsm or the result of cls(response) :rtype: @@ -372,7 +340,7 @@ async def begin_update( _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -390,12 +358,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -405,22 +374,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.DedicatedHsm].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return AsyncLROPoller[_models.DedicatedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -431,57 +396,56 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the specified Azure Dedicated HSM. - :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM to delete. Required. + :param name: Name of the dedicated Hsm. Required. :type 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: @@ -489,13 +453,13 @@ async def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + 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 + raw_result = await self._delete_initial( resource_group_name=resource_group_name, name=name, api_version=api_version, @@ -504,11 +468,12 @@ async def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -517,33 +482,28 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.DedicatedHsm: """Gets the specified Azure dedicated HSM. - :param resource_group_name: The name of the Resource Group to which the dedicated hsm belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHsm or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -554,24 +514,22 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, name=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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -581,16 +539,12 @@ async def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -599,12 +553,11 @@ def list_by_resource_group( """The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. - :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param top: Maximum number of results to return. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedHsm or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -613,10 +566,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsmListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -627,24 +580,32 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHsmListResult", pipeline_response) @@ -654,11 +615,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,17 +632,12 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs" - } - @distributed_trace def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> AsyncIterable["_models.DedicatedHsm"]: """The List operation gets information about the dedicated HSMs associated with the subscription. :param top: Maximum number of results to return. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedHsm or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -690,10 +646,10 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsmListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -704,23 +660,31 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Asyn def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHsmListResult", pipeline_response) @@ -730,11 +694,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -747,12 +711,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs" - } - @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, name: str, **kwargs: Any ) -> AsyncIterable["_models.OutboundEnvironmentEndpoint"]: """Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the @@ -761,12 +721,11 @@ def list_outbound_network_dependencies_endpoints( Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. - :param resource_group_name: The name of the Resource Group to which the dedicated hsm belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of cls(response) :rtype: @@ -776,10 +735,10 @@ def list_outbound_network_dependencies_endpoints( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -790,24 +749,32 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) @@ -817,11 +784,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -833,7 +800,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}/outboundNetworkDependenciesEndpoints" - } diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_operations.py index be055a53066e..1a3ff81b03bc 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -18,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,23 +56,21 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.DedicatedHsmOperation"]: - """Get a list of Dedicated HSM operations. + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Get a list of Hardware Security Modules operations. - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DedicatedHsmOperation or the result of - cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperation] + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hardwaresecuritymodules.models.Operation] :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", "2021-11-30")) - cls: ClsType[_models.DedicatedHsmOperationListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,45 +81,51 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.DedicatedHsmOperation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHsmOperationListResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.DedicatedHsmError, pipeline_response) + 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": "/providers/Microsoft.HardwareSecurityModules/operations"} diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_private_endpoint_connections_operations.py index ba3b44253f74..986b7b9b5174 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -18,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, 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 ..._vendor import _convert_request from ...operations._private_endpoint_connections_operations import build_list_by_cloud_hsm_cluster_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -62,9 +66,8 @@ def list_by_cloud_hsm_cluster( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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: @@ -74,10 +77,10 @@ def list_by_cloud_hsm_cluster( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -88,24 +91,32 @@ def list_by_cloud_hsm_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cloud_hsm_cluster_request( + _request = build_list_by_cloud_hsm_cluster_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cloud_hsm_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -115,23 +126,19 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_cloud_hsm_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections" - } diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/__init__.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/__init__.py index 2f197fab7980..1a3fef0f829a 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/__init__.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/__init__.py @@ -7,33 +7,35 @@ # -------------------------------------------------------------------------- from ._models_py3 import ApiEntityReference -from ._models_py3 import BackupProperties -from ._models_py3 import CHsmError +from ._models_py3 import BackupRequestProperties +from ._models_py3 import BackupRestoreBaseResultProperties +from ._models_py3 import BackupRestoreRequestBaseProperties +from ._models_py3 import BackupResult +from ._models_py3 import BackupResultProperties from ._models_py3 import CloudHsmCluster -from ._models_py3 import CloudHsmClusterError from ._models_py3 import CloudHsmClusterListResult from ._models_py3 import CloudHsmClusterPatchParameters -from ._models_py3 import CloudHsmClusterPatchParametersProperties from ._models_py3 import CloudHsmClusterProperties from ._models_py3 import CloudHsmClusterResource -from ._models_py3 import CloudHsmClusterSecurityDomainProperties from ._models_py3 import CloudHsmClusterSku from ._models_py3 import CloudHsmProperties from ._models_py3 import DedicatedHsm from ._models_py3 import DedicatedHsmError from ._models_py3 import DedicatedHsmListResult -from ._models_py3 import DedicatedHsmOperation -from ._models_py3 import DedicatedHsmOperationDisplay -from ._models_py3 import DedicatedHsmOperationListResult from ._models_py3 import DedicatedHsmPatchParameters from ._models_py3 import DedicatedHsmProperties -from ._models_py3 import DedicatedHsmResource from ._models_py3 import EndpointDependency from ._models_py3 import EndpointDetail from ._models_py3 import Error +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse from ._models_py3 import ManagedServiceIdentity from ._models_py3 import NetworkInterface from ._models_py3 import NetworkProfile +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult from ._models_py3 import OutboundEnvironmentEndpoint from ._models_py3 import OutboundEnvironmentEndpointCollection from ._models_py3 import PrivateEndpoint @@ -46,23 +48,28 @@ from ._models_py3 import PrivateLinkServiceConnectionState from ._models_py3 import ProxyResource from ._models_py3 import Resource -from ._models_py3 import ResourceListResult -from ._models_py3 import RestoreProperties +from ._models_py3 import RestoreRequestProperties +from ._models_py3 import RestoreResult from ._models_py3 import Sku from ._models_py3 import SystemData -from ._models_py3 import SystemDataAutoGenerated from ._models_py3 import TrackedResource from ._models_py3 import UserAssignedIdentity +from ._hardware_security_modules_mgmt_client_enums import ActionType +from ._hardware_security_modules_mgmt_client_enums import ActivationState +from ._hardware_security_modules_mgmt_client_enums import AutoGeneratedDomainNameLabelScope +from ._hardware_security_modules_mgmt_client_enums import BackupRestoreOperationStatus from ._hardware_security_modules_mgmt_client_enums import CloudHsmClusterSkuFamily from ._hardware_security_modules_mgmt_client_enums import CloudHsmClusterSkuName from ._hardware_security_modules_mgmt_client_enums import CreatedByType from ._hardware_security_modules_mgmt_client_enums import IdentityType from ._hardware_security_modules_mgmt_client_enums import JsonWebKeyType from ._hardware_security_modules_mgmt_client_enums import ManagedServiceIdentityType +from ._hardware_security_modules_mgmt_client_enums import Origin from ._hardware_security_modules_mgmt_client_enums import PrivateEndpointConnectionProvisioningState from ._hardware_security_modules_mgmt_client_enums import PrivateEndpointServiceConnectionStatus from ._hardware_security_modules_mgmt_client_enums import ProvisioningState +from ._hardware_security_modules_mgmt_client_enums import PublicNetworkAccess from ._hardware_security_modules_mgmt_client_enums import SkuName from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -70,33 +77,35 @@ __all__ = [ "ApiEntityReference", - "BackupProperties", - "CHsmError", + "BackupRequestProperties", + "BackupRestoreBaseResultProperties", + "BackupRestoreRequestBaseProperties", + "BackupResult", + "BackupResultProperties", "CloudHsmCluster", - "CloudHsmClusterError", "CloudHsmClusterListResult", "CloudHsmClusterPatchParameters", - "CloudHsmClusterPatchParametersProperties", "CloudHsmClusterProperties", "CloudHsmClusterResource", - "CloudHsmClusterSecurityDomainProperties", "CloudHsmClusterSku", "CloudHsmProperties", "DedicatedHsm", "DedicatedHsmError", "DedicatedHsmListResult", - "DedicatedHsmOperation", - "DedicatedHsmOperationDisplay", - "DedicatedHsmOperationListResult", "DedicatedHsmPatchParameters", "DedicatedHsmProperties", - "DedicatedHsmResource", "EndpointDependency", "EndpointDetail", "Error", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", "ManagedServiceIdentity", "NetworkInterface", "NetworkProfile", + "Operation", + "OperationDisplay", + "OperationListResult", "OutboundEnvironmentEndpoint", "OutboundEnvironmentEndpointCollection", "PrivateEndpoint", @@ -109,22 +118,27 @@ "PrivateLinkServiceConnectionState", "ProxyResource", "Resource", - "ResourceListResult", - "RestoreProperties", + "RestoreRequestProperties", + "RestoreResult", "Sku", "SystemData", - "SystemDataAutoGenerated", "TrackedResource", "UserAssignedIdentity", + "ActionType", + "ActivationState", + "AutoGeneratedDomainNameLabelScope", + "BackupRestoreOperationStatus", "CloudHsmClusterSkuFamily", "CloudHsmClusterSkuName", "CreatedByType", "IdentityType", "JsonWebKeyType", "ManagedServiceIdentityType", + "Origin", "PrivateEndpointConnectionProvisioningState", "PrivateEndpointServiceConnectionStatus", "ProvisioningState", + "PublicNetworkAccess", "SkuName", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_hardware_security_modules_mgmt_client_enums.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_hardware_security_modules_mgmt_client_enums.py index 1daa42b9887c..f322c5adc643 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_hardware_security_modules_mgmt_client_enums.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_hardware_security_modules_mgmt_client_enums.py @@ -10,6 +10,40 @@ from azure.core import CaseInsensitiveEnumMeta +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class ActivationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of security domain activation.""" + + NOT_DEFINED = "NotDefined" + NOT_ACTIVATED = "NotActivated" + ACTIVE = "Active" + FAILED = "Failed" + UNKNOWN = "Unknown" + + +class AutoGeneratedDomainNameLabelScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Cloud HSM Cluster's auto-generated Domain Name Label Scope.""" + + TENANT_REUSE = "TenantReuse" + SUBSCRIPTION_REUSE = "SubscriptionReuse" + RESOURCE_GROUP_REUSE = "ResourceGroupReuse" + NO_REUSE = "NoReuse" + + +class BackupRestoreOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the backup/restore operation.""" + + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELLED = "Cancelled" + + class CloudHsmClusterSkuFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Sku family of the Cloud HSM Cluster.""" @@ -45,7 +79,7 @@ class JsonWebKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state.""" SUCCEEDED = "Succeeded" - """The dedicated HSM has been full provisioned.""" + """The dedicated HSM has been fully provisioned.""" PROVISIONING = "Provisioning" """The dedicated HSM is currently being provisioned.""" ALLOCATING = "Allocating" @@ -71,6 +105,16 @@ class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state.""" @@ -96,11 +140,18 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): PROVISIONING = "Provisioning" SUCCEEDED = "Succeeded" + UPDATING = "Updating" FAILED = "Failed" DELETING = "Deleting" CANCELED = "Canceled" +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Cloud HSM Cluster public network access.""" + + DISABLED = "Disabled" + + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SKU of the dedicated HSM.""" @@ -108,19 +159,19 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The dedicated HSM is a Safenet Luna Network HSM A790 device.""" PAY_SHIELD10_K_LMK1_CPS60 = "payShield10K_LMK1_CPS60" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 1 local master key which supports up to 60 calls per second.""" + 1 local master key which supports up to 60 calls per second.""" PAY_SHIELD10_K_LMK1_CPS250 = "payShield10K_LMK1_CPS250" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 1 local master key which supports up to 250 calls per second.""" + 1 local master key which supports up to 250 calls per second.""" PAY_SHIELD10_K_LMK1_CPS2500 = "payShield10K_LMK1_CPS2500" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 1 local master key which supports up to 2500 calls per second.""" + 1 local master key which supports up to 2500 calls per second.""" PAY_SHIELD10_K_LMK2_CPS60 = "payShield10K_LMK2_CPS60" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 2 local master keys which supports up to 60 calls per second.""" + 2 local master keys which supports up to 60 calls per second.""" PAY_SHIELD10_K_LMK2_CPS250 = "payShield10K_LMK2_CPS250" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 2 local master keys which supports up to 250 calls per second.""" + 2 local master keys which supports up to 250 calls per second.""" PAY_SHIELD10_K_LMK2_CPS2500 = "payShield10K_LMK2_CPS2500" """The dedicated HSM is a payShield 10K, model PS10-D, 10Gb Ethernet Hardware Platform device with - #: 2 local master keys which supports up to 2500 calls per second.""" + 2 local master keys which supports up to 2500 calls per second.""" diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_models_py3.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_models_py3.py index fc6809318ec1..b4075fd4df0f 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_models_py3.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/models/_models_py3.py @@ -20,86 +20,223 @@ class ApiEntityReference(_serialization.Model): """The API entity reference. - :ivar id: The ARM resource id in the form of + :ivar resource_id: The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str + :vartype resource_id: str """ _attribute_map = { - "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + def __init__(self, *, resource_id: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword id: The ARM resource id in the form of + :keyword resource_id: The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str + :paramtype resource_id: str """ super().__init__(**kwargs) - self.id = id + self.resource_id = resource_id -class BackupProperties(_serialization.Model): - """Cloud Hsm Cluster backup information. +class BackupRestoreRequestBaseProperties(_serialization.Model): + """Backup and Restore Common properties. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. - :ivar azure_storage_resource_uri: Azure storage Resource Uri. - :vartype azure_storage_resource_uri: str - :ivar last_backup_date_time: Last Date Time that Customer Enabled Backup was taken. - :vartype last_backup_date_time: ~datetime.datetime - :ivar last_backup_status: Status of last backup. - :vartype last_backup_status: str + :ivar azure_storage_blob_container_uri: The Azure blob storage container Uri which contains the + backup. Required. + :vartype azure_storage_blob_container_uri: str + :ivar token: The SAS token pointing to an Azure blob storage container. This property is + reserved for Azure Backup Service. + :vartype token: str """ _validation = { - "last_backup_date_time": {"readonly": True}, - "last_backup_status": {"readonly": True}, + "azure_storage_blob_container_uri": {"required": True}, } _attribute_map = { - "azure_storage_resource_uri": {"key": "azureStorageResourceUri", "type": "str"}, - "last_backup_date_time": {"key": "lastBackupDateTime", "type": "iso-8601"}, - "last_backup_status": {"key": "lastBackupStatus", "type": "str"}, + "azure_storage_blob_container_uri": {"key": "azureStorageBlobContainerUri", "type": "str"}, + "token": {"key": "token", "type": "str"}, } - def __init__(self, *, azure_storage_resource_uri: Optional[str] = None, **kwargs: Any) -> None: + def __init__(self, *, azure_storage_blob_container_uri: str, token: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword azure_storage_resource_uri: Azure storage Resource Uri. - :paramtype azure_storage_resource_uri: str + :keyword azure_storage_blob_container_uri: The Azure blob storage container Uri which contains + the backup. Required. + :paramtype azure_storage_blob_container_uri: str + :keyword token: The SAS token pointing to an Azure blob storage container. This property is + reserved for Azure Backup Service. + :paramtype token: str """ super().__init__(**kwargs) - self.azure_storage_resource_uri = azure_storage_resource_uri - self.last_backup_date_time = None - self.last_backup_status = None + self.azure_storage_blob_container_uri = azure_storage_blob_container_uri + self.token = token + + +class BackupRequestProperties(BackupRestoreRequestBaseProperties): + """Backup properties. + All required parameters must be populated in order to send to server. -class CHsmError(_serialization.Model): - """Error details. + :ivar azure_storage_blob_container_uri: The Azure blob storage container Uri which contains the + backup. Required. + :vartype azure_storage_blob_container_uri: str + :ivar token: The SAS token pointing to an Azure blob storage container. This property is + reserved for Azure Backup Service. + :vartype token: str + """ + + +class BackupRestoreBaseResultProperties(_serialization.Model): + """Backup and Restore operation common properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str + :ivar status: Status of the backup/restore operation. Known values are: "InProgress", + "Succeeded", "Failed", and "Cancelled". + :vartype status: str or ~azure.mgmt.hardwaresecuritymodules.models.BackupRestoreOperationStatus + :ivar status_details: The status details of backup/restore operation. + :vartype status_details: str + :ivar error: Error encountered, if any, during the backup/restore operation. + :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + :ivar start_time: The start time of the backup/restore operation in UTC. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the backup/restore operation in UTC. + :vartype end_time: ~datetime.datetime + :ivar job_id: Identifier for the backup/restore operation. + :vartype job_id: str """ _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, } _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "status_details": {"key": "statusDetails", "type": "str"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "job_id": {"key": "jobId", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + status_details: Optional[str] = None, + error: Optional["_models.ErrorDetail"] = None, + job_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status_details: The status details of backup/restore operation. + :paramtype status_details: str + :keyword error: Error encountered, if any, during the backup/restore operation. + :paramtype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + :keyword job_id: Identifier for the backup/restore operation. + :paramtype job_id: str + """ super().__init__(**kwargs) - self.code = None - self.message = None + self.status = None + self.status_details = status_details + self.error = error + self.start_time = None + self.end_time = None + self.job_id = job_id + + +class BackupResult(_serialization.Model): + """Backup operation Result. + + :ivar properties: Properties of the Cloud HSM Cluster. + :vartype properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupResultProperties + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "BackupResultProperties"}, + } + + def __init__(self, *, properties: Optional["_models.BackupResultProperties"] = None, **kwargs: Any) -> None: + """ + :keyword properties: Properties of the Cloud HSM Cluster. + :paramtype properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupResultProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BackupResultProperties(BackupRestoreBaseResultProperties): + """Properties of the Cloud HSM Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: Status of the backup/restore operation. Known values are: "InProgress", + "Succeeded", "Failed", and "Cancelled". + :vartype status: str or ~azure.mgmt.hardwaresecuritymodules.models.BackupRestoreOperationStatus + :ivar status_details: The status details of backup/restore operation. + :vartype status_details: str + :ivar error: Error encountered, if any, during the backup/restore operation. + :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + :ivar start_time: The start time of the backup/restore operation in UTC. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the backup/restore operation in UTC. + :vartype end_time: ~datetime.datetime + :ivar job_id: Identifier for the backup/restore operation. + :vartype job_id: str + :ivar azure_storage_blob_container_uri: The Azure blob storage container Uri which contains the + backup. + :vartype azure_storage_blob_container_uri: str + :ivar backup_id: The ID of the backup. + :vartype backup_id: str + """ + + _validation = { + "status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "status_details": {"key": "statusDetails", "type": "str"}, + "error": {"key": "error", "type": "ErrorDetail"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "job_id": {"key": "jobId", "type": "str"}, + "azure_storage_blob_container_uri": {"key": "azureStorageBlobContainerUri", "type": "str"}, + "backup_id": {"key": "backupId", "type": "str"}, + } + + def __init__( + self, + *, + status_details: Optional[str] = None, + error: Optional["_models.ErrorDetail"] = None, + job_id: Optional[str] = None, + azure_storage_blob_container_uri: Optional[str] = None, + backup_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword status_details: The status details of backup/restore operation. + :paramtype status_details: str + :keyword error: Error encountered, if any, during the backup/restore operation. + :paramtype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + :keyword job_id: Identifier for the backup/restore operation. + :paramtype job_id: str + :keyword azure_storage_blob_container_uri: The Azure blob storage container Uri which contains + the backup. + :paramtype azure_storage_blob_container_uri: str + :keyword backup_id: The ID of the backup. + :paramtype backup_id: str + """ + super().__init__(status_details=status_details, error=error, job_id=job_id, **kwargs) + self.azure_storage_blob_container_uri = azure_storage_blob_container_uri + self.backup_id = backup_id class Resource(_serialization.Model): @@ -108,7 +245,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -149,10 +286,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -202,10 +339,10 @@ class CloudHsmClusterResource(TrackedResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -219,10 +356,10 @@ class CloudHsmClusterResource(TrackedResource): :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :ivar identity: Managed service identity (system assigned and/or user assigned identities). :vartype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku """ _validation = { @@ -240,8 +377,8 @@ class CloudHsmClusterResource(TrackedResource): "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "CloudHsmClusterSku"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "sku": {"key": "sku", "type": "CloudHsmClusterSku"}, } def __init__( @@ -249,8 +386,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.CloudHsmClusterSku"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, + sku: Optional["_models.CloudHsmClusterSku"] = None, **kwargs: Any ) -> None: """ @@ -258,14 +395,14 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :keyword identity: Managed service identity (system assigned and/or user assigned identities). :paramtype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :keyword sku: SKU details. + :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku """ super().__init__(tags=tags, location=location, **kwargs) - self.sku = sku self.identity = identity + self.sku = sku class CloudHsmCluster(CloudHsmClusterResource): @@ -273,10 +410,10 @@ class CloudHsmCluster(CloudHsmClusterResource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -290,10 +427,10 @@ class CloudHsmCluster(CloudHsmClusterResource): :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :ivar identity: Managed service identity (system assigned and/or user assigned identities). :vartype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :ivar sku: SKU details. + :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :ivar properties: Properties of the Cloud HSM Cluster. :vartype properties: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterProperties """ @@ -313,8 +450,8 @@ class CloudHsmCluster(CloudHsmClusterResource): "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "CloudHsmClusterSku"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "sku": {"key": "sku", "type": "CloudHsmClusterSku"}, "properties": {"key": "properties", "type": "CloudHsmClusterProperties"}, } @@ -323,8 +460,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.CloudHsmClusterSku"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, + sku: Optional["_models.CloudHsmClusterSku"] = None, properties: Optional["_models.CloudHsmClusterProperties"] = None, **kwargs: Any ) -> None: @@ -333,37 +470,17 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :keyword identity: Managed service identity (system assigned and/or user assigned identities). :paramtype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :keyword sku: SKU details. + :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :keyword properties: Properties of the Cloud HSM Cluster. :paramtype properties: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterProperties """ - super().__init__(tags=tags, location=location, sku=sku, identity=identity, **kwargs) + super().__init__(tags=tags, location=location, identity=identity, sku=sku, **kwargs) self.properties = properties -class CloudHsmClusterError(_serialization.Model): - """The Cloud HSM Cluster error details. - - :ivar error: Error details. - :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.CHsmError - """ - - _attribute_map = { - "error": {"key": "error", "type": "CHsmError"}, - } - - def __init__(self, *, error: Optional["_models.CHsmError"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error details. - :paramtype error: ~azure.mgmt.hardwaresecuritymodules.models.CHsmError - """ - super().__init__(**kwargs) - self.error = error - - class CloudHsmClusterListResult(_serialization.Model): """List of Cloud HSM Clusters. @@ -397,67 +514,31 @@ class CloudHsmClusterPatchParameters(_serialization.Model): :ivar tags: The Cloud HSM Cluster's tags. :vartype tags: dict[str, str] - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :ivar identity: Managed service identity (system assigned and/or user assigned identities). :vartype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity - :ivar properties: Properties of the Cloud HSM Cluster. - :vartype properties: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterPatchParametersProperties """ _attribute_map = { "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "CloudHsmClusterSku"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, - "properties": {"key": "properties", "type": "CloudHsmClusterPatchParametersProperties"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.CloudHsmClusterSku"] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, - properties: Optional["_models.CloudHsmClusterPatchParametersProperties"] = None, **kwargs: Any ) -> None: """ :keyword tags: The Cloud HSM Cluster's tags. :paramtype tags: dict[str, str] - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :keyword identity: Managed service identity (system assigned and/or user assigned identities). :paramtype identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity - :keyword properties: Properties of the Cloud HSM Cluster. - :paramtype properties: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterPatchParametersProperties """ super().__init__(**kwargs) self.tags = tags - self.sku = sku self.identity = identity - self.properties = properties - - -class CloudHsmClusterPatchParametersProperties(_serialization.Model): - """Properties of the Cloud HSM Cluster. - - :ivar backup_properties: Cloud Hsm Cluster backup information. - :vartype backup_properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupProperties - """ - - _attribute_map = { - "backup_properties": {"key": "backupProperties", "type": "BackupProperties"}, - } - - def __init__(self, *, backup_properties: Optional["_models.BackupProperties"] = None, **kwargs: Any) -> None: - """ - :keyword backup_properties: Cloud Hsm Cluster backup information. - :paramtype backup_properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupProperties - """ - super().__init__(**kwargs) - self.backup_properties = backup_properties class CloudHsmClusterProperties(_serialization.Model): @@ -465,127 +546,81 @@ class CloudHsmClusterProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The Cloud HSM Cluster's provisioningState. Known values are: - "Provisioning", "Succeeded", "Failed", "Deleting", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.hardwaresecuritymodules.models.ProvisioningState + :ivar activation_state: State of security domain activation. Known values are: "NotDefined", + "NotActivated", "Active", "Failed", and "Unknown". + :vartype activation_state: str or ~azure.mgmt.hardwaresecuritymodules.models.ActivationState :ivar auto_generated_domain_name_label_scope: The Cloud HSM Cluster's auto-generated Domain - Name Label Scope. - :vartype auto_generated_domain_name_label_scope: str - :ivar security_domain: Security domain properties information for Cloud HSM cluster. - :vartype security_domain: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSecurityDomainProperties + Name Label Scope. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", + and "NoReuse". + :vartype auto_generated_domain_name_label_scope: str or + ~azure.mgmt.hardwaresecuritymodules.models.AutoGeneratedDomainNameLabelScope :ivar hsms: An array of Cloud HSM Cluster's HSMs. :vartype hsms: list[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmProperties] - :ivar public_network_access: The Cloud HSM Cluster public network access. - :vartype public_network_access: str :ivar private_endpoint_connections: List of private endpoint connection resources. :vartype private_endpoint_connections: list[~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection] + :ivar provisioning_state: The Cloud HSM Cluster's provisioningState. Known values are: + "Provisioning", "Succeeded", "Updating", "Failed", "Deleting", and "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.hardwaresecuritymodules.models.ProvisioningState + :ivar public_network_access: The Cloud HSM Cluster public network access. "Disabled" + :vartype public_network_access: str or + ~azure.mgmt.hardwaresecuritymodules.models.PublicNetworkAccess :ivar status_message: Cloud HSM Cluster status message. :vartype status_message: str - :ivar restore_properties: Cloud Hsm Cluster restore information. - :vartype restore_properties: ~azure.mgmt.hardwaresecuritymodules.models.RestoreProperties - :ivar backup_properties: Cloud Hsm Cluster backup information. - :vartype backup_properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupProperties """ _validation = { + "activation_state": {"readonly": True}, + "hsms": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, "status_message": {"readonly": True}, } _attribute_map = { - "provisioning_state": {"key": "provisioningState", "type": "str"}, + "activation_state": {"key": "activationState", "type": "str"}, "auto_generated_domain_name_label_scope": {"key": "autoGeneratedDomainNameLabelScope", "type": "str"}, - "security_domain": {"key": "securityDomain", "type": "CloudHsmClusterSecurityDomainProperties"}, "hsms": {"key": "hsms", "type": "[CloudHsmProperties]"}, - "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, "status_message": {"key": "statusMessage", "type": "str"}, - "restore_properties": {"key": "restoreProperties", "type": "RestoreProperties"}, - "backup_properties": {"key": "backupProperties", "type": "BackupProperties"}, } def __init__( self, *, - provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, - auto_generated_domain_name_label_scope: Optional[str] = None, - security_domain: Optional["_models.CloudHsmClusterSecurityDomainProperties"] = None, - hsms: Optional[List["_models.CloudHsmProperties"]] = None, - public_network_access: Optional[str] = None, - private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, - restore_properties: Optional["_models.RestoreProperties"] = None, - backup_properties: Optional["_models.BackupProperties"] = None, + auto_generated_domain_name_label_scope: Optional[ + Union[str, "_models.AutoGeneratedDomainNameLabelScope"] + ] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs: Any ) -> None: """ - :keyword provisioning_state: The Cloud HSM Cluster's provisioningState. Known values are: - "Provisioning", "Succeeded", "Failed", "Deleting", and "Canceled". - :paramtype provisioning_state: str or - ~azure.mgmt.hardwaresecuritymodules.models.ProvisioningState :keyword auto_generated_domain_name_label_scope: The Cloud HSM Cluster's auto-generated Domain - Name Label Scope. - :paramtype auto_generated_domain_name_label_scope: str - :keyword security_domain: Security domain properties information for Cloud HSM cluster. - :paramtype security_domain: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSecurityDomainProperties - :keyword hsms: An array of Cloud HSM Cluster's HSMs. - :paramtype hsms: list[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmProperties] - :keyword public_network_access: The Cloud HSM Cluster public network access. - :paramtype public_network_access: str - :keyword private_endpoint_connections: List of private endpoint connection resources. - :paramtype private_endpoint_connections: - list[~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection] - :keyword restore_properties: Cloud Hsm Cluster restore information. - :paramtype restore_properties: ~azure.mgmt.hardwaresecuritymodules.models.RestoreProperties - :keyword backup_properties: Cloud Hsm Cluster backup information. - :paramtype backup_properties: ~azure.mgmt.hardwaresecuritymodules.models.BackupProperties + Name Label Scope. Known values are: "TenantReuse", "SubscriptionReuse", "ResourceGroupReuse", + and "NoReuse". + :paramtype auto_generated_domain_name_label_scope: str or + ~azure.mgmt.hardwaresecuritymodules.models.AutoGeneratedDomainNameLabelScope + :keyword public_network_access: The Cloud HSM Cluster public network access. "Disabled" + :paramtype public_network_access: str or + ~azure.mgmt.hardwaresecuritymodules.models.PublicNetworkAccess """ super().__init__(**kwargs) - self.provisioning_state = provisioning_state + self.activation_state = None self.auto_generated_domain_name_label_scope = auto_generated_domain_name_label_scope - self.security_domain = security_domain - self.hsms = hsms + self.hsms = None + self.private_endpoint_connections = None + self.provisioning_state = None self.public_network_access = public_network_access - self.private_endpoint_connections = private_endpoint_connections self.status_message = None - self.restore_properties = restore_properties - self.backup_properties = backup_properties - - -class CloudHsmClusterSecurityDomainProperties(_serialization.Model): - """Security domain properties information for Cloud HSM cluster. - - :ivar fips_state: FIPS state information for security domain. - :vartype fips_state: int - :ivar activation_status: status of security domain activation. - :vartype activation_status: str - """ - - _attribute_map = { - "fips_state": {"key": "fipsState", "type": "int"}, - "activation_status": {"key": "activationStatus", "type": "str"}, - } - - def __init__( - self, *, fips_state: Optional[int] = None, activation_status: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword fips_state: FIPS state information for security domain. - :paramtype fips_state: int - :keyword activation_status: status of security domain activation. - :paramtype activation_status: str - """ - super().__init__(**kwargs) - self.fips_state = fips_state - self.activation_status = activation_status class CloudHsmClusterSku(_serialization.Model): """Cloud Hsm Cluster SKU information. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar family: Sku family of the Cloud HSM Cluster. "B" :vartype family: str or ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSkuFamily @@ -635,7 +670,8 @@ class CloudHsmProperties(_serialization.Model): :ivar fqdn: FQDN of the Cloud HSM. :vartype fqdn: str - :ivar state: The Cloud HSM State. + :ivar state: The Cloud HSM State. Values are: Deploying, ConfiguringSlb, Starting, Starting, + Failed, Failed, Deleting, DeletingSlbEntry, InitialProvisioning, Updating. :vartype state: str :ivar state_message: The Cloud HSM State message. :vartype state_message: str @@ -658,7 +694,8 @@ def __init__( """ :keyword fqdn: FQDN of the Cloud HSM. :paramtype fqdn: str - :keyword state: The Cloud HSM State. + :keyword state: The Cloud HSM State. Values are: Deploying, ConfiguringSlb, Starting, Starting, + Failed, Failed, Deleting, DeletingSlbEntry, InitialProvisioning, Updating. :paramtype state: str :keyword state_message: The Cloud HSM State message. :paramtype state_message: str @@ -669,101 +706,32 @@ def __init__( self.state_message = state_message -class DedicatedHsmResource(_serialization.Model): - """Dedicated HSM resource. +class DedicatedHsm(TrackedResource): + """Resource information with extended details. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. - :ivar id: The Azure Resource Manager resource ID for the dedicated HSM. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str - :ivar name: The name of the dedicated HSM. + :ivar name: The name of the resource. :vartype name: str - :ivar type: The resource type of the dedicated HSM. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: The supported Azure location where the dedicated HSM should be created. - Required. - :vartype location: str - :ivar sku: SKU details. - :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku - :ivar zones: The Dedicated Hsm zones. - :vartype zones: list[str] + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.hardwaresecuritymodules.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "location": {"required": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "sku": {"key": "sku", "type": "Sku"}, - "zones": {"key": "zones", "type": "[str]"}, - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__( - self, - *, - location: str, - sku: Optional["_models.Sku"] = None, - zones: Optional[List[str]] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword location: The supported Azure location where the dedicated HSM should be created. - Required. - :paramtype location: str - :keyword sku: SKU details. - :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku - :keyword zones: The Dedicated Hsm zones. - :paramtype zones: list[str] - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = location - self.sku = sku - self.zones = zones - self.tags = tags - - -class DedicatedHsm(DedicatedHsmResource): - """Resource information with extended details. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The Azure Resource Manager resource ID for the dedicated HSM. - :vartype id: str - :ivar name: The name of the dedicated HSM. - :vartype name: str - :ivar type: The resource type of the dedicated HSM. - :vartype type: str - :ivar location: The supported Azure location where the dedicated HSM should be created. - Required. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar sku: SKU details. + :ivar sku: SKU details. Required. :vartype sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku :ivar zones: The Dedicated Hsm zones. :vartype zones: list[str] - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.hardwaresecuritymodules.models.SystemDataAutoGenerated :ivar properties: Properties of the dedicated HSM. Required. :vartype properties: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmProperties """ @@ -772,8 +740,9 @@ class DedicatedHsm(DedicatedHsmResource): "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "location": {"required": True}, "system_data": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, "properties": {"required": True}, } @@ -781,11 +750,11 @@ class DedicatedHsm(DedicatedHsmResource): "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "sku": {"key": "sku", "type": "Sku"}, "zones": {"key": "zones", "type": "[str]"}, - "tags": {"key": "tags", "type": "{str}"}, - "system_data": {"key": "systemData", "type": "SystemDataAutoGenerated"}, "properties": {"key": "properties", "type": "DedicatedHsmProperties"}, } @@ -793,27 +762,27 @@ def __init__( self, *, location: str, + sku: "_models.Sku", properties: "_models.DedicatedHsmProperties", - sku: Optional["_models.Sku"] = None, - zones: Optional[List[str]] = None, tags: Optional[Dict[str, str]] = None, + zones: Optional[List[str]] = None, **kwargs: Any ) -> None: """ - :keyword location: The supported Azure location where the dedicated HSM should be created. - Required. + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword sku: SKU details. + :keyword sku: SKU details. Required. :paramtype sku: ~azure.mgmt.hardwaresecuritymodules.models.Sku :keyword zones: The Dedicated Hsm zones. :paramtype zones: list[str] - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] :keyword properties: Properties of the dedicated HSM. Required. :paramtype properties: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmProperties """ - super().__init__(location=location, sku=sku, zones=zones, tags=tags, **kwargs) - self.system_data = None + super().__init__(tags=tags, location=location, **kwargs) + self.sku = sku + self.zones = zones self.properties = properties @@ -827,161 +796,45 @@ class DedicatedHsmError(_serialization.Model): """ _validation = { - "error": {"readonly": True}, - } - - _attribute_map = { - "error": {"key": "error", "type": "Error"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.error = None - - -class DedicatedHsmListResult(_serialization.Model): - """List of dedicated HSMs. - - :ivar value: The list of dedicated HSMs. - :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - :ivar next_link: The URL to get the next set of dedicated hsms. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHsm]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.DedicatedHsm"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of dedicated HSMs. - :paramtype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] - :keyword next_link: The URL to get the next set of dedicated hsms. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class DedicatedHsmOperation(_serialization.Model): - """REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the Dedicated HSM Resource Provider Operation. - :vartype name: str - :ivar is_data_action: Gets or sets a value indicating whether it is a data plane action. - :vartype is_data_action: bool - :ivar origin: The origin of the operation. - :vartype origin: str - :ivar display: The display string. - :vartype display: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperationDisplay - """ - - _validation = { - "is_data_action": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "origin": {"key": "origin", "type": "str"}, - "display": {"key": "display", "type": "DedicatedHsmOperationDisplay"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - origin: Optional[str] = None, - display: Optional["_models.DedicatedHsmOperationDisplay"] = None, - **kwargs: Any - ) -> None: - """ - :keyword name: The name of the Dedicated HSM Resource Provider Operation. - :paramtype name: str - :keyword origin: The origin of the operation. - :paramtype origin: str - :keyword display: The display string. - :paramtype display: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperationDisplay - """ - super().__init__(**kwargs) - self.name = name - self.is_data_action = None - self.origin = origin - self.display = display - - -class DedicatedHsmOperationDisplay(_serialization.Model): - """The display string. - - :ivar provider: The Resource Provider of the operation. - :vartype provider: str - :ivar resource: Resource on which the operation is performed. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str - :ivar description: The object that represents the operation. - :vartype description: str - """ + "error": {"readonly": True}, + } _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, + "error": {"key": "error", "type": "Error"}, } - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: The Resource Provider of the operation. - :paramtype provider: str - :keyword resource: Resource on which the operation is performed. - :paramtype resource: str - :keyword operation: Operation type: Read, write, delete, etc. - :paramtype operation: str - :keyword description: The object that represents the operation. - :paramtype description: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description + self.error = None -class DedicatedHsmOperationListResult(_serialization.Model): - """Result of the request to list Dedicated HSM Provider operations. It contains a list of - operations. +class DedicatedHsmListResult(_serialization.Model): + """List of dedicated HSMs. - :ivar value: List of Dedicated HSM Resource Provider operations. - :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperation] + :ivar value: The list of dedicated HSMs. + :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] + :ivar next_link: The URL to get the next set of dedicated hsms. + :vartype next_link: str """ _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHsmOperation]"}, + "value": {"key": "value", "type": "[DedicatedHsm]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.DedicatedHsmOperation"]] = None, **kwargs: Any) -> None: + def __init__( + self, *, value: Optional[List["_models.DedicatedHsm"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword value: List of Dedicated HSM Resource Provider operations. - :paramtype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperation] + :keyword value: The list of dedicated HSMs. + :paramtype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] + :keyword next_link: The URL to get the next set of dedicated hsms. + :paramtype next_link: str """ super().__init__(**kwargs) self.value = value + self.next_link = next_link class DedicatedHsmPatchParameters(_serialization.Model): @@ -1173,12 +1026,104 @@ def __init__(self, **kwargs: Any) -> None: self.inner_error = None +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.hardwaresecuritymodules.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.hardwaresecuritymodules.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + class ManagedServiceIdentity(_serialization.Model): """Managed service identity (system assigned and/or user assigned identities). Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -1192,7 +1137,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.hardwaresecuritymodules.models.UserAssignedIdentity] @@ -1225,7 +1170,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.hardwaresecuritymodules.models.UserAssignedIdentity] @@ -1242,19 +1187,19 @@ class NetworkInterface(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The ARM resource id in the form of + :ivar resource_id: The Azure resource id in the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str + :vartype resource_id: str :ivar private_ip_address: Private Ip address of the interface. :vartype private_ip_address: str """ _validation = { - "id": {"readonly": True}, + "resource_id": {"readonly": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, "private_ip_address": {"key": "privateIpAddress", "type": "str"}, } @@ -1264,7 +1209,7 @@ def __init__(self, *, private_ip_address: Optional[str] = None, **kwargs: Any) - :paramtype private_ip_address: str """ super().__init__(**kwargs) - self.id = None + self.resource_id = None self.private_ip_address = private_ip_address @@ -1303,6 +1248,127 @@ def __init__( self.network_interfaces = network_interfaces +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.hardwaresecuritymodules.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.hardwaresecuritymodules.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.hardwaresecuritymodules.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.hardwaresecuritymodules.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + class OutboundEnvironmentEndpoint(_serialization.Model): """Egress endpoints which dedicated hsm service connects to for common purpose. @@ -1342,7 +1408,7 @@ class OutboundEnvironmentEndpointCollection(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.OutboundEnvironmentEndpoint] @@ -1400,7 +1466,7 @@ class ProxyResource(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. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1412,24 +1478,6 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.hardwaresecuritymodules.models.SystemData """ - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - class PrivateEndpointConnection(ProxyResource): """The private endpoint connection resource. @@ -1437,7 +1485,7 @@ class PrivateEndpointConnection(ProxyResource): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1526,7 +1574,7 @@ class PrivateEndpointConnectionProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar private_endpoint: The private endpoint resource. :vartype private_endpoint: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpoint @@ -1587,7 +1635,7 @@ class PrivateLinkResource(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. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1628,12 +1676,21 @@ def __init__(self, *, properties: Optional["_models.PrivateLinkResourcePropertie class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar value: Array of private link resources. :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.PrivateLinkResource] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs: Any) -> None: @@ -1643,6 +1700,7 @@ def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = Non """ super().__init__(**kwargs) self.value = value + self.next_link = None class PrivateLinkResourceProperties(_serialization.Model): @@ -1726,64 +1784,73 @@ def __init__( self.actions_required = actions_required -class ResourceListResult(_serialization.Model): - """List of dedicated HSM resources. +class RestoreRequestProperties(BackupRestoreRequestBaseProperties): + """Cloud Hsm Cluster restore information. - :ivar value: The list of dedicated HSM resources. - :vartype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmResource] - :ivar next_link: The URL to get the next set of dedicated HSM resources. - :vartype next_link: str + All required parameters must be populated in order to send to server. + + :ivar azure_storage_blob_container_uri: The Azure blob storage container Uri which contains the + backup. Required. + :vartype azure_storage_blob_container_uri: str + :ivar token: The SAS token pointing to an Azure blob storage container. This property is + reserved for Azure Backup Service. + :vartype token: str + :ivar backup_id: An autogenerated unique string ID for labeling the backup. It contains both a + UUID and a date timestamp. Required. + :vartype backup_id: str """ + _validation = { + "azure_storage_blob_container_uri": {"required": True}, + "backup_id": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[DedicatedHsmResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "azure_storage_blob_container_uri": {"key": "azureStorageBlobContainerUri", "type": "str"}, + "token": {"key": "token", "type": "str"}, + "backup_id": {"key": "backupId", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["_models.DedicatedHsmResource"]] = None, - next_link: Optional[str] = None, - **kwargs: Any + self, *, azure_storage_blob_container_uri: str, backup_id: str, token: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword value: The list of dedicated HSM resources. - :paramtype value: list[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmResource] - :keyword next_link: The URL to get the next set of dedicated HSM resources. - :paramtype next_link: str + :keyword azure_storage_blob_container_uri: The Azure blob storage container Uri which contains + the backup. Required. + :paramtype azure_storage_blob_container_uri: str + :keyword token: The SAS token pointing to an Azure blob storage container. This property is + reserved for Azure Backup Service. + :paramtype token: str + :keyword backup_id: An autogenerated unique string ID for labeling the backup. It contains both + a UUID and a date timestamp. Required. + :paramtype backup_id: str """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link + super().__init__(azure_storage_blob_container_uri=azure_storage_blob_container_uri, token=token, **kwargs) + self.backup_id = backup_id -class RestoreProperties(_serialization.Model): - """Cloud Hsm Cluster restore information. +class RestoreResult(_serialization.Model): + """Restore operation properties. - :ivar foldername: Directory name in Azure Storage Blob where the backup is stored. - :vartype foldername: str - :ivar azure_storage_resource_uri: Azure Blob storage container Uri. - :vartype azure_storage_resource_uri: str + :ivar properties: Backup and Restore operation common properties. + :vartype properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRestoreBaseResultProperties """ _attribute_map = { - "foldername": {"key": "foldername", "type": "str"}, - "azure_storage_resource_uri": {"key": "azureStorageResourceUri", "type": "str"}, + "properties": {"key": "properties", "type": "BackupRestoreBaseResultProperties"}, } def __init__( - self, *, foldername: Optional[str] = None, azure_storage_resource_uri: Optional[str] = None, **kwargs: Any + self, *, properties: Optional["_models.BackupRestoreBaseResultProperties"] = None, **kwargs: Any ) -> None: """ - :keyword foldername: Directory name in Azure Storage Blob where the backup is stored. - :paramtype foldername: str - :keyword azure_storage_resource_uri: Azure Blob storage container Uri. - :paramtype azure_storage_resource_uri: str + :keyword properties: Backup and Restore operation common properties. + :paramtype properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRestoreBaseResultProperties """ super().__init__(**kwargs) - self.foldername = foldername - self.azure_storage_resource_uri = azure_storage_resource_uri + self.properties = properties class Sku(_serialization.Model): @@ -1875,71 +1942,6 @@ def __init__( self.last_modified_at = last_modified_at -class SystemDataAutoGenerated(_serialization.Model): - """Metadata pertaining to creation and last modification of dedicated hsm resource. - - :ivar created_by: The identity that created dedicated hsm resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created dedicated hsm resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.hardwaresecuritymodules.models.IdentityType - :ivar created_at: The timestamp of dedicated hsm resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified dedicated hsm resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified dedicated hsm resource. - Known values are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.hardwaresecuritymodules.models.IdentityType - :ivar last_modified_at: The timestamp of dedicated hsm resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, - } - - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.IdentityType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.IdentityType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created dedicated hsm resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created dedicated hsm resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.hardwaresecuritymodules.models.IdentityType - :keyword created_at: The timestamp of dedicated hsm resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified dedicated hsm resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified dedicated hsm resource. - Known values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.hardwaresecuritymodules.models.IdentityType - :keyword last_modified_at: The timestamp of dedicated hsm resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ - super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at - - class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/__init__.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/__init__.py index f36ee4ea2e1f..0101fac8d086 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/__init__.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/__init__.py @@ -12,8 +12,10 @@ CloudHsmClusterPrivateEndpointConnectionsOperations, ) from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations -from ._operations import Operations +from ._cloud_hsm_cluster_backup_status_operations import CloudHsmClusterBackupStatusOperations +from ._cloud_hsm_cluster_restore_status_operations import CloudHsmClusterRestoreStatusOperations from ._dedicated_hsm_operations import DedicatedHsmOperations +from ._operations import Operations from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import @@ -24,8 +26,10 @@ "CloudHsmClusterPrivateLinkResourcesOperations", "CloudHsmClusterPrivateEndpointConnectionsOperations", "PrivateEndpointConnectionsOperations", - "Operations", + "CloudHsmClusterBackupStatusOperations", + "CloudHsmClusterRestoreStatusOperations", "DedicatedHsmOperations", + "Operations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_backup_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_backup_status_operations.py new file mode 100644 index 000000000000..eab4d8ec0a20 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_backup_status_operations.py @@ -0,0 +1,169 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +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 + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, cloud_hsm_cluster_name: str, job_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", "2025-03-31")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backupOperationStatus/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + "jobId": _SERIALIZER.url("job_id", job_id, "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) + + +class CloudHsmClusterBackupStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hardwaresecuritymodules.HardwareSecurityModulesMgmtClient`'s + :attr:`cloud_hsm_cluster_backup_status` 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, resource_group_name: str, cloud_hsm_cluster_name: str, job_id: str, **kwargs: Any + ) -> Optional[_models.BackupResult]: + """Gets the backup operation status of the specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param job_id: The id returned as part of the backup request. Required. + :type job_id: str + :return: BackupResult or None or the result of cls(response) + :rtype: ~azure.mgmt.hardwaresecuritymodules.models.BackupResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Optional[_models.BackupResult]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py index fca7a5d9a6a3..aad667fcb3fa 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # 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, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_create_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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -61,9 +66,9 @@ def build_create_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), "peConnectionName": _SERIALIZER.url( "pe_connection_name", @@ -94,7 +99,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,9 +116,9 @@ def build_delete_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), "peConnectionName": _SERIALIZER.url( "pe_connection_name", @@ -142,7 +147,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,9 +164,9 @@ def build_get_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), "peConnectionName": _SERIALIZER.url( "pe_connection_name", @@ -184,7 +189,7 @@ def build_get_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class CloudHsmClusterPrivateEndpointConnectionsOperations: +class CloudHsmClusterPrivateEndpointConnectionsOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -220,7 +225,7 @@ def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. @@ -230,7 +235,6 @@ def create( :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: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -242,7 +246,7 @@ def create( resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, - properties: IO, + properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -253,17 +257,16 @@ def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_connection_name: str :param properties: Parameters of the PrivateEndpointConnection. Required. - :type properties: IO + :type properties: IO[bytes] :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: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -275,7 +278,7 @@ def create( resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, - properties: Union[_models.PrivateEndpointConnection, IO], + properties: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> _models.PrivateEndpointConnection: """Creates or updates the private endpoint connection for the Cloud Hsm Cluster. @@ -284,23 +287,20 @@ def create( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_connection_name: str :param properties: Parameters of the PrivateEndpointConnection. Is either a - PrivateEndpointConnection type or a IO type. Required. - :type properties: ~azure.mgmt.hardwaresecuritymodules.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 + PrivateEndpointConnection type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection or + IO[bytes] :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -311,7 +311,7 @@ def create( _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-12-10-preview")) + 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) @@ -323,7 +323,7 @@ def create( else: _json = self._serialize.body(properties, "PrivateEndpointConnection") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, @@ -332,40 +332,34 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, cloud_hsm_cluster_name: str, pe_connection_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -376,44 +370,47 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -425,19 +422,11 @@ def begin_delete( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_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: @@ -445,13 +434,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 + raw_result = self._delete_initial( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_name, @@ -461,11 +450,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -476,17 +466,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -498,17 +484,16 @@ def get( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param pe_connection_name: Name of the private endpoint connection associated with the Cloud HSM Cluster. Required. :type pe_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.hardwaresecuritymodules.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -519,41 +504,35 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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_request( + _request = build_get_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, pe_connection_name=pe_connection_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) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections/{peConnectionName}" - } + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_link_resources_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_link_resources_operations.py index 77fcc2fe8dbd..eaff4c49af38 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_link_resources_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # 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 +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,17 +18,20 @@ 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.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_cloud_hsm_cluster_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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,9 +62,9 @@ def build_list_by_cloud_hsm_cluster_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -74,7 +79,7 @@ def build_list_by_cloud_hsm_cluster_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -class CloudHsmClusterPrivateLinkResourcesOperations: +class CloudHsmClusterPrivateLinkResourcesOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -96,21 +101,27 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_by_cloud_hsm_cluster( self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any - ) -> _models.PrivateLinkResourceListResult: + ) -> Iterable["_models.PrivateLinkResource"]: """Gets the private link resources supported for the Cloud Hsm Cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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.hardwaresecuritymodules.models.PrivateLinkResourceListResult + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.PrivateLinkResource] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + _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) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -118,43 +129,57 @@ def list_by_cloud_hsm_cluster( } 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", "2023-12-10-preview")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - request = build_list_by_cloud_hsm_cluster_request( - resource_group_name=resource_group_name, - cloud_hsm_cluster_name=cloud_hsm_cluster_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_by_cloud_hsm_cluster.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.CloudHsmClusterError, 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 - - list_by_cloud_hsm_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateLinkResources" - } + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cloud_hsm_cluster_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", 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) diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_restore_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_restore_status_operations.py new file mode 100644 index 000000000000..1e7e21e24fea --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_cluster_restore_status_operations.py @@ -0,0 +1,169 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +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 + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, cloud_hsm_cluster_name: str, job_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", "2025-03-31")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restoreOperationStatus/{jobId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + "jobId": _SERIALIZER.url("job_id", job_id, "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) + + +class CloudHsmClusterRestoreStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hardwaresecuritymodules.HardwareSecurityModulesMgmtClient`'s + :attr:`cloud_hsm_cluster_restore_status` 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, resource_group_name: str, cloud_hsm_cluster_name: str, job_id: str, **kwargs: Any + ) -> Optional[_models.RestoreResult]: + """Gets the restore operation status of the specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param job_id: The id returned as part of the backup request. Required. + :type job_id: str + :return: RestoreResult or None or the result of cls(response) + :rtype: ~azure.mgmt.hardwaresecuritymodules.models.RestoreResult or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Optional[_models.RestoreResult]] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + job_id=job_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _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) + + deserialized = None + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + + if response.status_code == 202: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_clusters_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_clusters_operations.py index 86c94eea35d1..dba6f5415a62 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_clusters_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_cloud_hsm_clusters_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,10 @@ # 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, Iterable, Optional, TypeVar, Union, cast +from io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -14,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +50,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -61,9 +68,9 @@ def build_create_or_update_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -86,7 +93,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,9 +111,9 @@ def build_update_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -129,7 +136,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,9 +153,9 @@ def build_get_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -169,7 +176,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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,9 +193,9 @@ def build_delete_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -209,7 +216,7 @@ def build_list_by_resource_group_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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -243,7 +250,7 @@ def build_list_by_subscription_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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -267,6 +274,178 @@ def build_list_by_subscription_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_validate_backup_properties_request( + resource_group_name: str, cloud_hsm_cluster_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", "2025-03-31")) + 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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateBackupProperties", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_backup_request( + resource_group_name: str, cloud_hsm_cluster_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", "2025-03-31")) + 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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/backup", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_restore_properties_request( # pylint: disable=name-too-long + resource_group_name: str, cloud_hsm_cluster_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", "2025-03-31")) + 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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/validateRestoreProperties", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, cloud_hsm_cluster_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", "2025-03-31")) + 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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/restore", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "cloudHsmClusterName": _SERIALIZER.url( + "cloud_hsm_cluster_name", + cloud_hsm_cluster_name, + "str", + max_length=23, + min_length=3, + pattern=r"^[a-zA-Z0-9-]{3,23}$", + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class CloudHsmClustersOperations: """ .. warning:: @@ -292,12 +471,12 @@ def _create_or_update_initial( cloud_hsm_cluster_name: str, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, + sku: Optional[_models.CloudHsmClusterSku] = None, properties: Optional[_models.CloudHsmClusterProperties] = None, **kwargs: Any - ) -> _models.CloudHsmCluster: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,54 +487,49 @@ def _create_or_update_initial( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _body = _models.CloudHsmCluster(identity=identity, location=location, properties=properties, sku=sku, tags=tags) _json = self._serialize.body(_body, "CloudHsmCluster") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - 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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + 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("CloudHsmCluster", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } - @distributed_trace def begin_create_or_update( self, @@ -363,8 +537,8 @@ def begin_create_or_update( cloud_hsm_cluster_name: str, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, + sku: Optional[_models.CloudHsmClusterSku] = None, properties: Optional[_models.CloudHsmClusterProperties] = None, **kwargs: Any ) -> LROPoller[_models.CloudHsmCluster]: @@ -374,27 +548,19 @@ def begin_create_or_update( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param location: The geo-location where the resource lives. Required. :type location: str :param tags: Resource tags. Default value is None. :type tags: dict[str, str] - :param sku: SKU details. Default value is None. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param identity: Managed service identity (system assigned and/or user assigned identities). Default value is None. :type identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity + :param sku: SKU details. Default value is None. + :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param properties: Properties of the Cloud HSM Cluster. Default value is None. :type properties: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterProperties - :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 CloudHsmCluster or the result of cls(response) :rtype: @@ -404,7 +570,7 @@ def begin_create_or_update( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -416,8 +582,8 @@ def begin_create_or_update( cloud_hsm_cluster_name=cloud_hsm_cluster_name, location=location, tags=tags, - sku=sku, identity=identity, + sku=sku, properties=properties, api_version=api_version, content_type=content_type, @@ -426,12 +592,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -443,29 +610,25 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CloudHsmCluster].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return LROPoller[_models.CloudHsmCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, cloud_hsm_cluster_name: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, - properties: Optional[_models.CloudHsmClusterPatchParametersProperties] = None, **kwargs: Any - ) -> Optional[_models.CloudHsmCluster]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -476,55 +639,52 @@ def _update_initial( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[Optional[_models.CloudHsmCluster]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _body = _models.CloudHsmClusterPatchParameters(identity=identity, properties=properties, sku=sku, tags=tags) + _body = _models.CloudHsmClusterPatchParameters(identity=identity, tags=tags) _json = self._serialize.body(_body, "CloudHsmClusterPatchParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore @distributed_trace def begin_update( @@ -532,9 +692,7 @@ def begin_update( resource_group_name: str, cloud_hsm_cluster_name: str, tags: Optional[Dict[str, str]] = None, - sku: Optional[_models.CloudHsmClusterSku] = None, identity: Optional[_models.ManagedServiceIdentity] = None, - properties: Optional[_models.CloudHsmClusterPatchParametersProperties] = None, **kwargs: Any ) -> LROPoller[_models.CloudHsmCluster]: """Update a Cloud HSM Cluster in the specified subscription. @@ -543,26 +701,13 @@ def begin_update( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str :param tags: The Cloud HSM Cluster's tags. Default value is None. :type tags: dict[str, str] - :param sku: SKU details. Default value is None. - :type sku: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterSku :param identity: Managed service identity (system assigned and/or user assigned identities). Default value is None. :type identity: ~azure.mgmt.hardwaresecuritymodules.models.ManagedServiceIdentity - :param properties: Properties of the Cloud HSM Cluster. Default value is None. - :type properties: - ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmClusterPatchParametersProperties - :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 CloudHsmCluster or the result of cls(response) :rtype: @@ -572,7 +717,7 @@ def begin_update( _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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -583,9 +728,7 @@ def begin_update( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, tags=tags, - sku=sku, identity=identity, - properties=properties, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -593,12 +736,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -610,17 +754,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CloudHsmCluster].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return LROPoller[_models.CloudHsmCluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get(self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any) -> _models.CloudHsmCluster: @@ -630,14 +772,13 @@ def get(self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: A Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CloudHsmCluster or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -648,48 +789,40 @@ def get(self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmCluster] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_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) + _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 + _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.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CloudHsmCluster", pipeline_response) + deserialized = self._deserialize("CloudHsmCluster", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -700,43 +833,46 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CloudHsmClusterError, pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, cloud_hsm_cluster_name: str, **kwargs: Any) -> LROPoller[None]: @@ -746,16 +882,8 @@ def begin_delete(self, resource_group_name: str, cloud_hsm_cluster_name: str, ** Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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: @@ -763,13 +891,13 @@ def begin_delete(self, resource_group_name: str, cloud_hsm_cluster_name: str, ** _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 + raw_result = self._delete_initial( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, api_version=api_version, @@ -778,11 +906,12 @@ def begin_delete(self, resource_group_name: str, cloud_hsm_cluster_name: str, ** params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -793,17 +922,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_by_resource_group( @@ -818,7 +943,6 @@ def list_by_resource_group( :param skiptoken: The page-continuation token to use with a paged version of this API. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CloudHsmCluster or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster] @@ -827,10 +951,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -841,24 +965,32 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, skiptoken=skiptoken, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CloudHsmClusterListResult", pipeline_response) @@ -868,27 +1000,23 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters" - } - @distributed_trace def list_by_subscription( self, skiptoken: Optional[str] = None, **kwargs: Any @@ -899,7 +1027,6 @@ def list_by_subscription( :param skiptoken: The page-continuation token to use with a paged version of this API. Default value is None. :type skiptoken: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CloudHsmCluster or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.CloudHsmCluster] @@ -908,10 +1035,10 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CloudHsmClusterListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -922,23 +1049,31 @@ def list_by_subscription( def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, skiptoken=skiptoken, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("CloudHsmClusterListResult", pipeline_response) @@ -948,23 +1083,898 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters" - } + def _validate_backup_properties_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(backup_request_properties, (IOBase, bytes)): + _content = backup_request_properties + else: + if backup_request_properties is not None: + _json = self._serialize.body(backup_request_properties, "BackupRequestProperties") + else: + _json = None + + _request = build_validate_backup_properties_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[_models.BackupRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Default value is None. + :type backup_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_backup_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Pre Backup operation to validate whether the customer can perform a backup on the Cloud HSM + Cluster resource in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Backup Operation Required properties. Is either a + BackupRequestProperties type or a IO[bytes] type. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties or IO[bytes] + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :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.BackupResult] = 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._validate_backup_properties_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + backup_request_properties=backup_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _backup_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(backup_request_properties, (IOBase, bytes)): + _content = backup_request_properties + else: + if backup_request_properties is not None: + _json = self._serialize.body(backup_request_properties, "BackupRequestProperties") + else: + _json = None + + _request = build_backup_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[_models.BackupRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Default value is None. + :type backup_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_backup( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + backup_request_properties: Optional[Union[_models.BackupRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.BackupResult]: + """Create a backup of the Cloud HSM Cluster in the specified subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param backup_request_properties: Azure storage Resource Uri. Is either a + BackupRequestProperties type or a IO[bytes] type. Default value is None. + :type backup_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.BackupRequestProperties or IO[bytes] + :return: An instance of LROPoller that returns either BackupResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.BackupResult] + :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.BackupResult] = 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._backup_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + backup_request_properties=backup_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("BackupResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.BackupResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.BackupResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _validate_restore_properties_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[Union[_models.RestoreRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(restore_request_properties, (IOBase, bytes)): + _content = restore_request_properties + else: + if restore_request_properties is not None: + _json = self._serialize.body(restore_request_properties, "RestoreRequestProperties") + else: + _json = None + + _request = build_validate_restore_properties_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[_models.RestoreRequestProperties] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Default value is None. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Default value is None. + :type restore_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate_restore_properties( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Optional[Union[_models.RestoreRequestProperties, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Queued validating pre restore operation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Optional Parameters to validate prior performing a restore + operation. Is either a RestoreRequestProperties type or a IO[bytes] type. Default value is + None. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties or IO[bytes] + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :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.RestoreResult] = 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._validate_restore_properties_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + restore_request_properties=restore_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RestoreResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RestoreResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _restore_initial( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Union[_models.RestoreRequestProperties, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 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[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(restore_request_properties, (IOBase, bytes)): + _content = restore_request_properties + else: + _json = self._serialize.body(restore_request_properties, "RestoreRequestProperties") + + _request = build_restore_request( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + 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) + + response_headers = {} + if response.status_code == 200: + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: _models.RestoreRequestProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Required. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Required. + :type restore_request_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore( + self, + resource_group_name: str, + cloud_hsm_cluster_name: str, + restore_request_properties: Union[_models.RestoreRequestProperties, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.RestoreResult]: + """Restores all key materials of a specified Cloud HSM Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. + :type cloud_hsm_cluster_name: str + :param restore_request_properties: Restore Operation Required properties. Is either a + RestoreRequestProperties type or a IO[bytes] type. Required. + :type restore_request_properties: + ~azure.mgmt.hardwaresecuritymodules.models.RestoreRequestProperties or IO[bytes] + :return: An instance of LROPoller that returns either RestoreResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.RestoreResult] + :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.RestoreResult] = 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._restore_initial( + resource_group_name=resource_group_name, + cloud_hsm_cluster_name=cloud_hsm_cluster_name, + restore_request_properties=restore_request_properties, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["x-ms-request-id"] = self._deserialize("str", response.headers.get("x-ms-request-id")) + + deserialized = self._deserialize("RestoreResult", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.RestoreResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.RestoreResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py index 6d356569699a..159940d4404c 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_dedicated_hsm_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,9 @@ # 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 sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +50,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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -54,7 +60,9 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -76,7 +84,7 @@ def build_update_request(resource_group_name: str, name: str, subscription_id: s _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -86,7 +94,9 @@ def build_update_request(resource_group_name: str, name: str, subscription_id: s "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "name": _SERIALIZER.url("name", name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -108,7 +118,7 @@ def build_delete_request(resource_group_name: str, name: str, subscription_id: s _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,8 +127,10 @@ def build_delete_request(resource_group_name: str, name: str, subscription_id: s "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "name": _SERIALIZER.url("name", name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -137,7 +149,7 @@ def build_get_request(resource_group_name: str, name: str, subscription_id: str, _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,8 +158,10 @@ def build_get_request(resource_group_name: str, name: str, subscription_id: str, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "name": _SERIALIZER.url("name", name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -168,7 +182,7 @@ def build_list_by_resource_group_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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +191,9 @@ def build_list_by_resource_group_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -200,7 +216,7 @@ def build_list_by_subscription_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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -224,13 +240,13 @@ def build_list_by_subscription_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_outbound_network_dependencies_endpoints_request( +def build_list_outbound_network_dependencies_endpoints_request( # pylint: disable=name-too-long resource_group_name: str, 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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,8 +255,10 @@ def build_list_outbound_network_dependencies_endpoints_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}/outboundNetworkDependenciesEndpoints", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "name": _SERIALIZER.url("name", name, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "name": _SERIALIZER.url("name", name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -275,9 +293,9 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_or_update_initial( - self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO], **kwargs: Any - ) -> _models.DedicatedHsm: - error_map = { + self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -288,9 +306,9 @@ def _create_or_update_initial( _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", "2021-11-30")) + 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.DedicatedHsm] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -300,7 +318,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "DedicatedHsm") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, @@ -308,40 +326,35 @@ def _create_or_update_initial( 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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("DedicatedHsm", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } - @overload def begin_create_or_update( self, @@ -354,7 +367,7 @@ def begin_create_or_update( ) -> LROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. @@ -364,14 +377,6 @@ def begin_create_or_update( :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 DedicatedHsm or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -383,31 +388,23 @@ def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. :type name: str :param parameters: Parameters to create or update the dedicated hsm. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 DedicatedHsm or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -416,29 +413,18 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO], **kwargs: Any + self, resource_group_name: str, name: str, parameters: Union[_models.DedicatedHsm, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.DedicatedHsm]: """Create or Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the resource belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param name: Name of the dedicated Hsm. Required. :type name: str :param parameters: Parameters to create or update the dedicated hsm. Is either a DedicatedHsm - type or a IO type. Required. - :type parameters: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm 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. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm or IO[bytes] :return: An instance of LROPoller that returns either DedicatedHsm or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -447,7 +433,7 @@ def begin_create_or_update( _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", "2021-11-30")) + 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.DedicatedHsm] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -465,12 +451,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -480,22 +467,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DedicatedHsm].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return LROPoller[_models.DedicatedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, name: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any - ) -> _models.DedicatedHsm: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -506,49 +491,52 @@ def _update_initial( _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _parameters = _models.DedicatedHsmPatchParameters(tags=tags) _json = self._serialize.body(_parameters, "DedicatedHsmPatchParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, {}) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace def begin_update( @@ -556,21 +544,13 @@ def begin_update( ) -> LROPoller[_models.DedicatedHsm]: """Update a dedicated HSM in the specified subscription. - :param resource_group_name: The name of the Resource Group to which the server belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: Name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str :param tags: Resource tags. Default value is None. :type tags: dict[str, 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 DedicatedHsm or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] @@ -579,7 +559,7 @@ def begin_update( _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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -597,12 +577,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -612,22 +593,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.DedicatedHsm].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return LROPoller[_models.DedicatedHsm]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -638,57 +615,56 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified Azure Dedicated HSM. - :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM to delete. Required. + :param name: Name of the dedicated Hsm. Required. :type 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: @@ -696,13 +672,13 @@ def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> LR _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + 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 + raw_result = self._delete_initial( resource_group_name=resource_group_name, name=name, api_version=api_version, @@ -711,11 +687,12 @@ def begin_delete(self, resource_group_name: str, name: str, **kwargs: Any) -> LR params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -724,33 +701,28 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.DedicatedHsm: """Gets the specified Azure dedicated HSM. - :param resource_group_name: The name of the Resource Group to which the dedicated hsm belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHsm or the result of cls(response) :rtype: ~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -761,24 +733,22 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.Ded _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsm] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, name=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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -788,16 +758,12 @@ def get(self, resource_group_name: str, name: str, **kwargs: Any) -> _models.Ded error = self._deserialize.failsafe_deserialize(_models.DedicatedHsmError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("DedicatedHsm", pipeline_response) + deserialized = self._deserialize("DedicatedHsm", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group( @@ -806,12 +772,11 @@ def list_by_resource_group( """The List operation gets information about the dedicated hsms associated with the subscription and within the specified resource group. - :param resource_group_name: The name of the Resource Group to which the dedicated HSM belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str :param top: Maximum number of results to return. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedHsm or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: @@ -819,10 +784,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsmListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -833,24 +798,32 @@ def list_by_resource_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHsmListResult", pipeline_response) @@ -860,11 +833,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -877,17 +850,12 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs" - } - @distributed_trace def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iterable["_models.DedicatedHsm"]: """The List operation gets information about the dedicated HSMs associated with the subscription. :param top: Maximum number of results to return. Default value is None. :type top: int - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DedicatedHsm or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsm] :raises ~azure.core.exceptions.HttpResponseError: @@ -895,10 +863,10 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.DedicatedHsmListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -909,23 +877,31 @@ def list_by_subscription(self, top: Optional[int] = None, **kwargs: Any) -> Iter def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, top=top, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("DedicatedHsmListResult", pipeline_response) @@ -935,11 +911,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -952,12 +928,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs" - } - @distributed_trace - def list_outbound_network_dependencies_endpoints( + def list_outbound_network_dependencies_endpoints( # pylint: disable=name-too-long self, resource_group_name: str, name: str, **kwargs: Any ) -> Iterable["_models.OutboundEnvironmentEndpoint"]: """Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the @@ -966,12 +938,11 @@ def list_outbound_network_dependencies_endpoints( Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified dedicated hsm resource. The operation returns properties of each egress endpoint. - :param resource_group_name: The name of the Resource Group to which the dedicated hsm belongs. + :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param name: The name of the dedicated HSM. Required. + :param name: Name of the dedicated Hsm. Required. :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OutboundEnvironmentEndpoint or the result of cls(response) :rtype: @@ -981,10 +952,10 @@ def list_outbound_network_dependencies_endpoints( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OutboundEnvironmentEndpointCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -995,24 +966,32 @@ def list_outbound_network_dependencies_endpoints( def prepare_request(next_link=None): if not next_link: - request = build_list_outbound_network_dependencies_endpoints_request( + _request = build_list_outbound_network_dependencies_endpoints_request( resource_group_name=resource_group_name, name=name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_outbound_network_dependencies_endpoints.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("OutboundEnvironmentEndpointCollection", pipeline_response) @@ -1022,11 +1001,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1038,7 +1017,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_outbound_network_dependencies_endpoints.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/{name}/outboundNetworkDependenciesEndpoints" - } diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_operations.py index ab97fb1b4e57..352440c70e70 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # 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, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +43,7 @@ def build_list_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", "2021-11-30")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,23 +78,20 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.DedicatedHsmOperation"]: - """Get a list of Dedicated HSM operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DedicatedHsmOperation or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.DedicatedHsmOperation] + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Get a list of Hardware Security Modules operations. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hardwaresecuritymodules.models.Operation] :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", "2021-11-30")) - cls: ClsType[_models.DedicatedHsmOperationListResult] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -101,45 +102,51 @@ def list(self, **kwargs: Any) -> Iterable["_models.DedicatedHsmOperation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): - deserialized = self._deserialize("DedicatedHsmOperationListResult", pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.DedicatedHsmError, pipeline_response) + 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": "/providers/Microsoft.HardwareSecurityModules/operations"} diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_private_endpoint_connections_operations.py index e8151e2e0953..80c7a1975d3f 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_private_endpoint_connections_operations.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/azure/mgmt/hardwaresecuritymodules/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,9 @@ # 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, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,16 +20,18 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse 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 +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +45,7 @@ def build_list_by_cloud_hsm_cluster_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-12-10-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-03-31")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,9 +62,9 @@ def build_list_by_cloud_hsm_cluster_request( "cloud_hsm_cluster_name", cloud_hsm_cluster_name, "str", - max_length=24, + max_length=23, min_length=3, - pattern=r"^[a-zA-Z0-9-]{3,24}$", + pattern=r"^[a-zA-Z0-9-]{3,23}$", ), } @@ -105,9 +109,8 @@ def list_by_cloud_hsm_cluster( Required. :type resource_group_name: str :param cloud_hsm_cluster_name: The name of the Cloud HSM Cluster within the specified resource - group. Cloud HSM Cluster names must be between 3 and 24 characters in length. Required. + group. Cloud HSM Cluster names must be between 3 and 23 characters in length. Required. :type cloud_hsm_cluster_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: @@ -117,10 +120,10 @@ def list_by_cloud_hsm_cluster( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-10-preview")) + 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 = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -131,24 +134,32 @@ def list_by_cloud_hsm_cluster( def prepare_request(next_link=None): if not next_link: - request = build_list_by_cloud_hsm_cluster_request( + _request = build_list_by_cloud_hsm_cluster_request( resource_group_name=resource_group_name, cloud_hsm_cluster_name=cloud_hsm_cluster_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_cloud_hsm_cluster.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + # 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.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) @@ -158,23 +169,19 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _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.CloudHsmClusterError, pipeline_response) + 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_by_cloud_hsm_cluster.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/{cloudHsmClusterName}/privateEndpointConnections" - } diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_backup_pending_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_backup_pending_maximum_set_gen.py new file mode 100644 index 000000000000..ddb156eca406 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_backup_pending_maximum_set_gen.py @@ -0,0 +1,43 @@ +# 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.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hardwaresecuritymodules +# USAGE + python cloud_hsm_cluster_backup_pending_maximum_set_gen.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 = HardwareSecurityModulesMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.cloud_hsm_cluster_backup_status.get( + resource_group_name="rgcloudhsm", + cloud_hsm_cluster_name="chsm1", + job_id="572a45927fc240e1ac075de27371680b", + ) + print(response) + + +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_Backup_Pending_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_operations_list.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_create_or_validate_backup_maximum_set_gen.py similarity index 73% rename from sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_operations_list.py rename to sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_create_or_validate_backup_maximum_set_gen.py index f8ea8688d819..55df0d926b3b 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_operations_list.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_create_or_validate_backup_maximum_set_gen.py @@ -7,33 +7,34 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-hardwaresecuritymodules # USAGE - python dedicated_hsm_operations_list.py + python cloud_hsm_cluster_create_or_validate_backup_maximum_set_gen.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 = HardwareSecurityModulesMgmtClient( credential=DefaultAzureCredential(), - subscription_id="SUBSCRIPTION_ID", + subscription_id="00000000-0000-0000-0000-000000000000", ) - response = client.operations.list() - for item in response: - print(item) - + response = client.cloud_hsm_clusters.begin_backup( + resource_group_name='rgcloudhsm', + cloud_hsm_cluster_name='chsm1', + ).result() + print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_OperationsList.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_CreateOrValidate_Backup_MaximumSet_Gen.json if __name__ == "__main__": main() +main__": + main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_delete_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_delete_maximum_set_gen.py index a229d67bae70..6a223745ec6a 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_delete_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmCluster_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_get_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_get_maximum_set_gen.py index aef5ca57f2cd..0df96a0174ff 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_get_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmCluster_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_resource_group_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_resource_group_maximum_set_gen.py index 420b8c96f12e..9ff2e35353ff 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_resource_group_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_resource_group_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmCluster_ListByResourceGroup_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_ListByResourceGroup_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_subscription_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_subscription_maximum_set_gen.py index 75c890caea3e..6b52a37867fc 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_subscription_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_list_by_subscription_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmCluster_ListBySubscription_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_ListBySubscription_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_create_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_create_maximum_set_gen.py index 1be1d0e90f8c..3770e3ca3ba3 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_create_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_create_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -45,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_delete_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_delete_maximum_set_gen.py index ed3b9b479799..46a691347283 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_delete_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_delete_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmClusterPrivateEndpointConnection_Delete_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmClusterPrivateEndpointConnection_Delete_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_get_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_get_maximum_set_gen.py index 90bd05dcccf0..6f8f845c2e1c 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_get_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_get_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_list_by_cloud_hsm_cluster_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_list_by_cloud_hsm_cluster_maximum_set_gen.py index c3acebd01423..7674b763386e 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_list_by_cloud_hsm_cluster_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_endpoint_connection_list_by_cloud_hsm_cluster_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmClusterPrivateEndpointConnection_ListByCloudHsmCluster_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmClusterPrivateEndpointConnection_ListByCloudHsmCluster_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_link_resource_list_by_cloud_hsm_cluster_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_link_resource_list_by_cloud_hsm_cluster_maximum_set_gen.py index 779c9e150f79..37e099c0e18d 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_link_resource_list_by_cloud_hsm_cluster_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_private_link_resource_list_by_cloud_hsm_cluster_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -33,9 +34,10 @@ def main(): resource_group_name="rgcloudhsm", cloud_hsm_cluster_name="chsm1", ) - print(response) + for item in response: + print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmClusterPrivateLinkResource_ListByCloudHsmCluster_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmClusterPrivateLinkResource_ListByCloudHsmCluster_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_request_or_validate_restore_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_request_or_validate_restore_maximum_set_gen.py new file mode 100644 index 000000000000..3253e8d3addc --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_request_or_validate_restore_maximum_set_gen.py @@ -0,0 +1,46 @@ +# 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.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hardwaresecuritymodules +# USAGE + python cloud_hsm_cluster_request_or_validate_restore_maximum_set_gen.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 = HardwareSecurityModulesMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.cloud_hsm_clusters.begin_restore( + resource_group_name="rgcloudhsm", + cloud_hsm_cluster_name="chsm1", + restore_request_properties={ + "azureStorageBlobContainerUri": "https://myaccount.blob.core.windows.net/sascontainer/sasContainer", + "backupId": "backupId", + }, + ).result() + print(response) + + +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_RequestOrValidate_Restore_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_restore_pending_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_restore_pending_maximum_set_gen.py new file mode 100644 index 000000000000..1c2b8a45fc76 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_restore_pending_maximum_set_gen.py @@ -0,0 +1,43 @@ +# 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.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-hardwaresecuritymodules +# USAGE + python cloud_hsm_cluster_restore_pending_maximum_set_gen.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 = HardwareSecurityModulesMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.cloud_hsm_cluster_restore_status.get( + resource_group_name="rgcloudhsm", + cloud_hsm_cluster_name="chsm1", + job_id="572a45927fc240e1ac075de27371680b", + ) + print(response) + + +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_Restore_Pending_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_update_maximum_set_gen.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_update_maximum_set_gen.py index 659c5804df03..c8ee4e916d48 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_update_maximum_set_gen.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/cloud_hsm_cluster_update_maximum_set_gen.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2023-12-10-preview/examples/CloudHsmCluster_Update_MaximumSet_Gen.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/CloudHsmCluster_Update_MaximumSet_Gen.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_create_or_update.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_create_or_update.py index da511450962f..cc90f61320f6 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_create_or_update.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -38,7 +39,7 @@ def main(): "networkProfile": { "networkInterfaces": [{"privateIpAddress": "1.0.0.1"}], "subnet": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" }, }, "stampId": "stamp01", @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_CreateOrUpdate.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_delete.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_delete.py index 891aabb34bc2..ce02ec0a5aa8 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_delete.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_Delete.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_Delete.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_get.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_get.py index 1020a43196d6..7f15566f0990 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_get.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_Get.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_Get.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_resource_group.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_resource_group.py index a03d186bda0a..17a28c8dd08b 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_resource_group.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_ListByResourceGroup.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_subscription.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_subscription.py index 5fe893b6eb52..8ad3b8cc51aa 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_subscription.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_ListBySubscription.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_update.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_update.py index fe2b61e39b4e..80a28788254e 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_update.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/dedicated_hsm_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/DedicatedHsm_Update.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/DedicatedHsm_Update.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/get_outbound_network_dependencies_endpoints_list.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/get_outbound_network_dependencies_endpoints_list.py index a5ab7f6a510a..456f88f83808 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/get_outbound_network_dependencies_endpoints_list.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/get_outbound_network_dependencies_endpoints_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/GetOutboundNetworkDependenciesEndpointsList.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/GetOutboundNetworkDependenciesEndpointsList.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_operations_list.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/operations_list.py similarity index 90% rename from sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_operations_list.py rename to sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/operations_list.py index 77ff4d6a45f7..cbcf980a3733 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_operations_list.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -14,7 +15,7 @@ pip install azure-identity pip install azure-mgmt-hardwaresecuritymodules # USAGE - python payment_hsm_operations_list.py + python operations_list.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, @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_OperationsList.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/OperationsList.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update.py index 8d9c92be7a4a..d2a287b77ed8 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -38,7 +39,7 @@ def main(): "networkProfile": { "networkInterfaces": [{"privateIpAddress": "1.0.0.1"}], "subnet": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" }, }, "stampId": "stamp01", @@ -50,6 +51,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_CreateOrUpdate.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update_with_management_profile.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update_with_management_profile.py index 9acc7c6ba88f..e89cf8c0f83b 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update_with_management_profile.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_create_or_update_with_management_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -38,13 +39,13 @@ def main(): "managementNetworkProfile": { "networkInterfaces": [{"privateIpAddress": "1.0.0.2"}], "subnet": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" }, }, "networkProfile": { "networkInterfaces": [{"privateIpAddress": "1.0.0.1"}], "subnet": { - "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" + "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01" }, }, "stampId": "stamp01", @@ -56,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_CreateOrUpdate_WithManagementProfile.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_CreateOrUpdate_WithManagementProfile.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get.py index 0e89245ff1df..0c6720750fc4 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_Get.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_Get.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get_with_20181031_preview_version.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get_with_20181031_preview_version.py index 88878bd5cde3..33b7a13ed635 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get_with_20181031_preview_version.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_get_with_20181031_preview_version.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_resource_group.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_resource_group.py index 30291a2bdcd2..21a24cf63f31 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_resource_group.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_ListByResourceGroup.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_subscription.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_subscription.py index 7ffbd350fb55..d6c767bdcdf4 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_subscription.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_list_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_ListBySubscription.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_update.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_update.py index 6e3d1c33c886..9056cf8fd027 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_update.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_samples/payment_hsm_update.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2021-11-30/examples/PaymentHsm_Update.json +# x-ms-original-file: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/stable/2025-03-31/examples/PaymentHsm_Update.json if __name__ == "__main__": main() diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/conftest.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/conftest.py new file mode 100644 index 000000000000..1bb6264d8d2c --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + hardwaresecuritymodulesmgmt_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + hardwaresecuritymodulesmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + hardwaresecuritymodulesmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + hardwaresecuritymodulesmgmt_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=hardwaresecuritymodulesmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=hardwaresecuritymodulesmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=hardwaresecuritymodulesmgmt_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=hardwaresecuritymodulesmgmt_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations.py new file mode 100644 index 000000000000..c6a1dc9d3723 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterBackupStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cloud_hsm_cluster_backup_status.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + job_id="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations_async.py new file mode 100644 index 000000000000..b1b4843996d1 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_backup_status_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterBackupStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cloud_hsm_cluster_backup_status.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + job_id="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..6139085a8ae0 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations.py @@ -0,0 +1,82 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.cloud_hsm_cluster_private_endpoint_connections.create( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + properties={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.cloud_hsm_cluster_private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cloud_hsm_cluster_private_endpoint_connections.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..8436ed8dfa31 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_endpoint_connections_operations_async.py @@ -0,0 +1,87 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterPrivateEndpointConnectionsOperationsAsync( + AzureMgmtRecordedTestCase +): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.cloud_hsm_cluster_private_endpoint_connections.create( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + properties={ + "etag": "str", + "id": "str", + "name": "str", + "properties": { + "privateLinkServiceConnectionState": { + "actionsRequired": "str", + "description": "str", + "status": "str", + }, + "groupIds": ["str"], + "privateEndpoint": {"id": "str"}, + "provisioningState": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.cloud_hsm_cluster_private_endpoint_connections.begin_delete( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cloud_hsm_cluster_private_endpoint_connections.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + pe_connection_name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations.py new file mode 100644 index 000000000000..c05d440a8416 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterPrivateLinkResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cloud_hsm_cluster(self, resource_group): + response = self.client.cloud_hsm_cluster_private_link_resources.list_by_cloud_hsm_cluster( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations_async.py new file mode 100644 index 000000000000..4936ba569a15 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_private_link_resources_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterPrivateLinkResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cloud_hsm_cluster(self, resource_group): + response = self.client.cloud_hsm_cluster_private_link_resources.list_by_cloud_hsm_cluster( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations.py new file mode 100644 index 000000000000..12608fd0c47b --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterRestoreStatusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cloud_hsm_cluster_restore_status.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + job_id="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations_async.py new file mode 100644 index 000000000000..151e03751ce2 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_cluster_restore_status_operations_async.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClusterRestoreStatusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cloud_hsm_cluster_restore_status.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + job_id="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations.py new file mode 100644 index 000000000000..f6950a099b11 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClustersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_create_or_update( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + location="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_update( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.cloud_hsm_clusters.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_delete( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.cloud_hsm_clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.cloud_hsm_clusters.list_by_subscription( + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_validate_backup_properties(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_validate_backup_properties( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_backup(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_backup( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_validate_restore_properties(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_validate_restore_properties( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_restore(self, resource_group): + response = self.client.cloud_hsm_clusters.begin_restore( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + restore_request_properties={"azureStorageBlobContainerUri": "str", "backupId": "str", "token": "str"}, + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations_async.py new file mode 100644 index 000000000000..43b0c7d29f74 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_cloud_hsm_clusters_operations_async.py @@ -0,0 +1,153 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtCloudHsmClustersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_create_or_update( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + location="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_update( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.cloud_hsm_clusters.get( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_delete( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.cloud_hsm_clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.cloud_hsm_clusters.list_by_subscription( + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_validate_backup_properties(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_validate_backup_properties( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_backup(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_backup( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_validate_restore_properties(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_validate_restore_properties( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_restore(self, resource_group): + response = await ( + await self.client.cloud_hsm_clusters.begin_restore( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + restore_request_properties={"azureStorageBlobContainerUri": "str", "backupId": "str", "token": "str"}, + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations.py new file mode 100644 index 000000000000..473a9c3fd911 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations.py @@ -0,0 +1,130 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtDedicatedHsmOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.dedicated_hsm.begin_create_or_update( + resource_group_name=resource_group.name, + name="str", + parameters={ + "location": "str", + "properties": { + "managementNetworkProfile": { + "networkInterfaces": [{"privateIpAddress": "str", "resourceId": "str"}], + "subnet": {"resourceId": "str"}, + }, + "networkProfile": { + "networkInterfaces": [{"privateIpAddress": "str", "resourceId": "str"}], + "subnet": {"resourceId": "str"}, + }, + "provisioningState": "str", + "stampId": "str", + "statusMessage": "str", + }, + "sku": {"name": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.dedicated_hsm.begin_update( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.dedicated_hsm.begin_delete( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.dedicated_hsm.get( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.dedicated_hsm.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.dedicated_hsm.list_by_subscription( + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.dedicated_hsm.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations_async.py new file mode 100644 index 000000000000..87cd675b9a88 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_dedicated_hsm_operations_async.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtDedicatedHsmOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.dedicated_hsm.begin_create_or_update( + resource_group_name=resource_group.name, + name="str", + parameters={ + "location": "str", + "properties": { + "managementNetworkProfile": { + "networkInterfaces": [{"privateIpAddress": "str", "resourceId": "str"}], + "subnet": {"resourceId": "str"}, + }, + "networkProfile": { + "networkInterfaces": [{"privateIpAddress": "str", "resourceId": "str"}], + "subnet": {"resourceId": "str"}, + }, + "provisioningState": "str", + "stampId": "str", + "statusMessage": "str", + }, + "sku": {"name": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "zones": ["str"], + }, + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.dedicated_hsm.begin_update( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.dedicated_hsm.begin_delete( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.dedicated_hsm.get( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.dedicated_hsm.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.dedicated_hsm.list_by_subscription( + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_outbound_network_dependencies_endpoints(self, resource_group): + response = self.client.dedicated_hsm.list_outbound_network_dependencies_endpoints( + resource_group_name=resource_group.name, + name="str", + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations.py new file mode 100644 index 000000000000..a7df4a9d6e9c --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations_async.py new file mode 100644 index 000000000000..2585efa2900b --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..b05a4dbc17dd --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtPrivateEndpointConnectionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cloud_hsm_cluster(self, resource_group): + response = self.client.private_endpoint_connections.list_by_cloud_hsm_cluster( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations_async.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations_async.py new file mode 100644 index 000000000000..c356fcb33ae8 --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/generated_tests/test_hardware_security_modules_mgmt_private_endpoint_connections_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.hardwaresecuritymodules.aio import HardwareSecurityModulesMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHardwareSecurityModulesMgmtPrivateEndpointConnectionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(HardwareSecurityModulesMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cloud_hsm_cluster(self, resource_group): + response = self.client.private_endpoint_connections.list_by_cloud_hsm_cluster( + resource_group_name=resource_group.name, + cloud_hsm_cluster_name="str", + api_version="2025-03-31", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/setup.py b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/setup.py index 2d192f58df88..0f483531e6cc 100644 --- a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/setup.py +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/setup.py @@ -74,9 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", )